Map<String,String> m1=new HashMap<String,String>();
m1.put("zara", "name1");
m1.put("mahnaz","31");
m1.put("Ayna", "name2");
m1.put("zara","kkk");
System.out.println(m1.get("zara"));
System.out.println(m1.hashCode());
//1.
for(Map.Entry<String, String> entry : m1.entrySet())
{
System.out.println(entry.getKey()+":"+entry.getValue());

}
//2.
Set<String> keyset=m1.keySet();
Iterator<String> iterator=keyset.iterator();
while (iterator.hasNext()) {
String mkey=iterator.next();
String mvlaue=m1.get(mkey);
System.out.println(mkey+":"+mvlaue);

}
//3.
Collection<String> collection=m1.values();
Iterator<String> iterator2=collection.iterator();
while (iterator2.hasNext()) {
System.out.println(iterator.next());
}

--------------------------------------------

Java中key可以重复的Map集合:IdentityHashMap

https://blog.csdn.net/u013159040/article/details/49000225

List和Map是Java中最常用到的集合类

https://blog.csdn.net/u012951323/article/details/52854175

Java Map 集合类简介

https://blog.csdn.net/casularm/article/details/164877

05-16 05:56