java 集合操作小结
Posted chengjunde
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 集合操作小结相关的知识,希望对你有一定的参考价值。
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
以上是关于java 集合操作小结的主要内容,如果未能解决你的问题,请参考以下文章
201671010129 2016—2017—2 《Java程序设计》学习Java的集合的小结