版权声明:本文为博主原创文章。 https://blog.csdn.net/qq_36691683/article/details/88429555
Map的keySet()方法返回的Set对象是不支持addAll()方法的,否则就会产生UnsupportedOperationException
如何解决:
Map map =new HashMap();
map.put("key", "value");
Map map1 =new HashMap();
map1.put("key", "value");
Set set=new HashSet();
set.addAll(map.keySet());
set.addAll(map1.keySet());