java_菜鸟,遍历map,与set

Java代码
Map<String,String> map=new HashMap<String,String>();   
map.put("username", "qq");   
map.put("passWord", "123");   
map.put("userID", "1");   
map.put("email", "[email protected]");  
Map<String,String> map=new HashMap<String,String>();
map.put("username", "qq");
map.put("passWord", "123");
map.put("userID", "1");
map.put("email", "[email protected]");
Java代码

for(Map.Entry<String, String> entry:map.entrySet()){   
     System.out.println(entry.getKey()+"--->"+entry.getValue());   
}  



set集合:
迭代遍历: 
Set<String> set = new HashSet<String>(); 
Iterator<String> it = set.iterator(); 
while (it.hasNext()) { 
  String str = it.next(); 
  System.out.println(str); 
}
 
2.for循环遍历: 
for (String str : set) { 
      System.out.println(str); 
}

你可能感兴趣的:(java)