public class User {
public static void main(String[] args){
Map<String,String> map=new HashMap<String, String>();
map.put("赵", "a");
map.put("钱", "b");
map.put("孙", "c");
map.put("李", "d");
map.put("网", "c");
System.out.println(map.size());
System.out.println("------------------");
System.out.println(map.get("钱"));
System.out.println("------------------");
for(String in:map.keySet()){ //先找到键
String str=map.get(in); //再找到值
System.out.println(in+"\t"+str);
}
System.out.println("---------------");
for(Map.Entry<String, String> entry:map.entrySet()){ //推荐,尤其是容量大时
System.out.println("key:"+entry.getKey()+"\t"+"value="+entry.getValue());
}
System.out.println("--------------");
for(String value:map.values()){//只能找到值
System.out.println(value);
}
}
}
public static void main(String[] args){
Map<String,String> map=new HashMap<String, String>();
map.put("赵", "a");
map.put("钱", "b");
map.put("孙", "c");
map.put("李", "d");
map.put("网", "c");
System.out.println(map.size());
System.out.println("------------------");
System.out.println(map.get("钱"));
System.out.println("------------------");
for(String in:map.keySet()){ //先找到键
String str=map.get(in); //再找到值
System.out.println(in+"\t"+str);
}
System.out.println("---------------");
for(Map.Entry<String, String> entry:map.entrySet()){ //推荐,尤其是容量大时
System.out.println("key:"+entry.getKey()+"\t"+"value="+entry.getValue());
}
System.out.println("--------------");
for(String value:map.values()){//只能找到值
System.out.println(value);
}
}
}