map中常用的方法
put(k,v);添加值
package com.example.demo.controller; import java.util.HashMap; import java.util.Map; public class MapTesy { public static void main(String[] args) { Map map = new HashMap(); Map map1 = new HashMap(); map.put("1","我"); map.put(2,5); System.out.println(map); System.out.println(map1); map1.put(3,465); map1.put(4,456); map.putAll(map1); System.out.println(map); System.out.println(map1); map1.clear(); System.out.println(map1); System.out.println(map.containsKey("1")); System.out.println(map.containsKey(2)); } }
putAll(map);添加map集合
clear();清楚集合
containsKey();是否包含主键