package com.test;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import com.test.bean.Person;
public class Test {
public static void main(String[] args){
Test a = new Test();
a.map();
}
public void map(){
Map<String,Person> personMap = new HashMap<String, Person>();
Person temp = null;
for(int i=1;i<5;i++){
temp = new Person();
temp.setName("geg"+i);
temp.setSex("boy");
temp.setAge(i);
personMap.put(String.valueOf(i), temp);
}
//1
// for(Entry<String,Person> entry:personMap.entrySet()){
//
// System.out.println("age==="+entry.getValue().getAge());
//
// }
//2
// for(Person tempPer : personMap.values()){
// System.out.println("age==="+tempPer.getAge());
// }
//3
// for(String key:personMap.keySet()){
// System.out.println("age=="+personMap.get(key).getAge());
// }
//4
Iterator<Entry<String,Person>> it = personMap.entrySet().iterator();
while(it.hasNext()){
Entry<String,Person> entry = it.next();
System.out.println("age=="+entry.getValue().getAge());
}
}
}