1. 代码
publicstaticvoidmain(String[]args){
List>list1=newArrayList>();
MapcontractMap=newHashMap();
contractMap.put("CONTRACTID","1");
contractMap.put("CONTRACTCODE",2);
list1.add(contractMap);
List>list2=newArrayList>();
MapcontractMap2=newHashMap();
contractMap2.put("CONTRACTID","1");
contractMap2.put("CONTRACTCODE",2);
MapcontractMap3=newHashMap();
contractMap3.put("CONTRACTID","1");
contractMap3.put("CONTRACTCODE",3);
list2.add(contractMap2);
list2.add(contractMap3);
//先添加list2list1.addAll(list2);
//更新list2的第一个元素list2.get(1).put("CONTRACTCODE",5);
list2.remove(0);
//打印list1的第二个元素System.out.println(list1.get(1).get("CONTRACTCODE"));
System.out.println(list1.get(2).get("CONTRACTCODE"));
System.out.println(list2.get(0).get("CONTRACTCODE"));
System.out.println(list1.size());
//list1.removeAll(list2);//list2.removeAll(list1);System.out.println(list1.size());
System.out.println(list2.size());
if(contractMap.equals(contractMap2)){
System.out.println("Y");
}else{
System.out.println("N");
}
/*finalintlen=13;
System.out.println((len&0xFF));
if((len&0x01)!=0){
}
try{
InputStreamis=newFileInputStream(newFile("D:\\5w.xlsx"));
byte[]bytes=readBytes(is);
System.out.println(bytes.length);
}catch(Exceptione){
e.printStackTrace();
}*/
}
"com.intellij.rt.execution.application.AppMainHexTest
2
5
5
3
3
1
Y
2. 总结
1. List1的addAlll(List2) 修改List2里的对象元素List1会跟着改变(说明List2的中的元素添加到List1是使用的对象的地址传递,修改2元素1的元素跟着修改)
2.对集合的操作(remove) 只是正对集合,比如List1添加2的元素,List2呢remove一个元素对List1来说List1仍然有List2移除的元素
3. removeAll使用的contains而contains使用的是equals比较的是值