// Map<String, Integer> m=new HashMap<String ,Integer>(); //按key取出value
// m.put("1", 3);
// System.out.println(m.get("1")); //取出key对应的value 3
// Map<String, Integer> m=new HashMap<String ,Integer>(); //修改map中的值
// m.put("1", 3);
// m.put("1",m.get("1")+1);
// System.out.println(m.get("1")); //把原来的key覆盖掉
// m.get("1")+=1; //错误,不能这样修改 左边的为数值(非变量),不能说数值等于数值
// Map<String, Integer> m=new HashMap<String ,Integer>(); //遍历
// m.put("1", 13);
// m.put("2", 25);
// m.put("8", 10);
// Collection<Integer> ce=m.values();
// for(Integer temp : ce){ //前面的参数为个体实例,后面的参数为数组
// System.out.println(temp);
// }
// 输出为
// 25
// 13
// 10
// 不按顺序的
Map HashMap Collection
最新推荐文章于 2022-04-12 14:39:46 发布