List<User> list1 = new ArrayList<>();
List<User> list2 = new ArrayList<>();
User user1 = new User("a1",1);
list1.add(new User("a1",1));
list1.add(new User("a2",2));
list1.add(new User("a3",3));
list1.add(new User("a4",4));
list2.add(new User("a1",1));
list2.add(new User("a5",2));
list2.add(new User("a6",3));
list2.add(new User("a2",4));
Map<String,Integer> map = new HashMap<>(list2.size());
List<User> differentList = new ArrayList<>();
for(User storeOut: list2){
map.put(storeOut.getName(),1);
}
for(User storeOut1 : list1){
if(map.get(storeOut1.getName())==null){
differentList.add(storeOut1);
}
}
for (int i = 0; i < differentList.size() ; i++) {
System.out.println(differentList.get(i).getName());
}