[color=red][b]针对基础类型:[/b][/color]
ArrayList<String> result = new ArrayList<String>();
for(String s: sources){
if(Collections.frequency(reslut, s) < 1) result.add(s);
}
LinkedHashSet<String> set = new LinkedHashSet<String>(rules);
ArrayList<String> newRules = new ArrayList<String>(set);
[color=red][b]针对对象类型:[/b][/color]
去除ArrayList<Object>里面
/**标签:return,color,ArrayList,userList,去除,new,重复记录,LinkedHashSet From: https://blog.51cto.com/u_3871599/6138536
* 将列表中重复的用户移除,重复指的是userid相同
* @param userList
* @return
*/
public ArrayList<UserInfo> removeDuplicteUsers(ArrayList<UserInfo> userList){
Set<UserInfo> s= new TreeSet<UserInfo>(new Comparator<UserInfo>(){
@Override
public int compare(UserInfo o1, UserInfo o2) {
return o1.userId.compareTo(o2.userId);
}
});
s.addAll(userList);
return new ArrayList<UserInfo>(s);
}