HashSet
2015-09-10 10:31
253 查看
package test.lindl.mor;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class Test2 {
public static void main(String[] args) {
HashMap<String, String> hashMap=new HashMap<String,String>();
hashMap.put("qq", "qq");
hashMap.put("ww", "ww");
hashMap.put("ee", "ee");
hashMap.put("aa", "aa");
hashMap.put("ss", "ss");
hashMap.put("dd", "dd");
System.out.println("---------Collection Value----------");
Collection<String> collection=hashMap.values();
for(String str: collection){
System.out.println(str);
}
System.out.println("----------KeySet Key------------");
Set<String> set=hashMap.keySet();
java.util.Iterator<String> it=set.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
System.out.println("-----------Map Entry---------");
Set<Map.Entry<String, String>> kvSet=hashMap.entrySet();
java.util.Iterator<Map.Entry<String, String>> it2=kvSet.iterator();
while(it2.hasNext()){
Map.Entry<String, String> map=it2.next();
System.out.println("key:"+map.getKey()+" "+"value:"+map.getValue());
}
}
}
---------Collection Value----------
dd
ee
ww
ss
aa
qq
----------KeySet Key------------
dd
ee
ww
ss
aa
qq
-----------Map Entry---------
key:dd value:dd
key:ee value:ee
key:ww value:ww
key:ss value:ss
key:aa value:aa
key:qq value:qq
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class Test2 {
public static void main(String[] args) {
HashMap<String, String> hashMap=new HashMap<String,String>();
hashMap.put("qq", "qq");
hashMap.put("ww", "ww");
hashMap.put("ee", "ee");
hashMap.put("aa", "aa");
hashMap.put("ss", "ss");
hashMap.put("dd", "dd");
System.out.println("---------Collection Value----------");
Collection<String> collection=hashMap.values();
for(String str: collection){
System.out.println(str);
}
System.out.println("----------KeySet Key------------");
Set<String> set=hashMap.keySet();
java.util.Iterator<String> it=set.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
System.out.println("-----------Map Entry---------");
Set<Map.Entry<String, String>> kvSet=hashMap.entrySet();
java.util.Iterator<Map.Entry<String, String>> it2=kvSet.iterator();
while(it2.hasNext()){
Map.Entry<String, String> map=it2.next();
System.out.println("key:"+map.getKey()+" "+"value:"+map.getValue());
}
}
}
---------Collection Value----------
dd
ee
ww
ss
aa
----------KeySet Key------------
dd
ee
ww
ss
aa
-----------Map Entry---------
key:dd value:dd
key:ee value:ee
key:ww value:ww
key:ss value:ss
key:aa value:aa
key:qq value:qq
相关文章推荐
- Bash shell常用技巧
- JavaScript prototype实例
- 浅析C++中的static
- linux kill 关闭进程命令
- CentOS修改系统时间
- hdu 1025 Constructing Roads In JGShining's Kingdom 最长上升序列nlogn
- mina的HTTP性能测试
- 论volatile
- 浅析C++中的static
- hdu 1025 Constructing Roads In JGShining's Kingdom 最长上升序列nlogn
- linux sock_raw原始套接字
- 如何创建phpinfo查看php信息?
- MySQL查询优化-explain
- JSP 6个常用标签
- Scanner学习总结
- c++文件操作:2深入
- 使用achartengine绘制折线图
- 神经性皮炎如何治疗
- Android 更新UI的两种方法——handler和runOnUiThread()
- error:/usr/bin/ld:skipping incompatible ./libxxxx.so