list a= new ArrayList();
list b=new ArrayList();
a.add("1");
a.add("2");
a.add("3");
a.add("4");
b.add("2");
b.add("3");
要求输出结果为:
b no 1
b has 2
b has 3
b no 4
[code="java"]for(string str:b){
if(a.contains(str)){
System.out.println("b has "+str);
}else{
System.out.println("b no"+str);
}
}[/code]
手写的没测! 试试看哦!!!
不是很明白
应该用Map储存
//0代表未选中
List allUser = new ArrayList();//{"1","2","3","4","5","6"};
List currentUser = new ArrayList();//{"1","2","3","4"};
Map userMap = new HashMap();
forearch(String str : allUser ){
userMap.put(str,0);//0代表未选中
}
forearch(String str : currentUser ){
userMap.put(str,1);//1代表未选中
}
结果就是
1,1
2,1
3,1
4,1
5,0
6,0
选中了1,2,3,4 这四个