本帖最后由 郭阳 于 2012-9-25 13:41 编辑
HashMap<Student,Teacher> hm=new HashMap<Student,Teacher>();
hm.put(new Student("student01",11),new Teacher("teacher01",21));
hm.put(new Student("student02",12),new Teacher("teacher02",22));
hm.put(new Student("student03",13),new Teacher("teacher03",23));
Set<Map.Entry<Student,Teacher>> hs=hm.entrySet();
Iterator<Map.Entry<Student,Teacher>> it=hs.iterator();
while(it.hasNext())
{
Map.Entry<Student,Teacher> me=it.next();
Student s=me.getKey();
Teacher t=me.getValue()·········································}
----------------------------------------------------------------------------------------------------------------------------------------
谁能说说这段代码在堆栈中的情况啊
Map集合创建的时候,对象是先封装在Map.Entry对象中再存的还是?
Map.Entry对象me是一个引用吗?那他实体中存的是学生实体还是学生引用?
|