Map<Integer,String> test = new HashMap<Integer,String>();
test.put(1, "aaa");
test.put(2, "bbb");
test.put(3, "ccc");
test.put(4, "ddd");
Iterator it =test.entrySet().iterator();
while(it.hasNext()){
Map.Entry<Integer,String> helloEntry =(Map.Entry<Integer,String>)
it.next();
System.out.println( helloEntry.getKey()+"-----"+helloEntry.getValue()); }
for(Map.Entry<Integer,String> m : test.entrySet()){
System.out.println(m.getKey()+"----"+m.getValue());
}
Iterator<Integer> it = test.keySet().iterator();
while(it.hasNext()){
int key = it.next();
System.out.println(key+"--keyset--"+test.get(key)); }
for(Object m :test.keySet()){
int key = (int) m;
System.out.println(m+"--nadaoduixiang--"+test.get(m));
}
描述:map集合
test.put(1, "aaa");
test.put(2, "bbb");
test.put(3, "ccc");
test.put(4, "ddd");
Iterator it =test.entrySet().iterator();
while(it.hasNext()){
Map.Entry<Integer,String> helloEntry =(Map.Entry<Integer,String>)
it.next();
System.out.println( helloEntry.getKey()+"-----"+helloEntry.getValue()); }
for(Map.Entry<Integer,String> m : test.entrySet()){
System.out.println(m.getKey()+"----"+m.getValue());
}
Iterator<Integer> it = test.keySet().iterator();
while(it.hasNext()){
int key = it.next();
System.out.println(key+"--keyset--"+test.get(key)); }
for(Object m :test.keySet()){
int key = (int) m;
System.out.println(m+"--nadaoduixiang--"+test.get(m));
}
描述:map集合