I have a list for user IDs. It consists of user IDs selected from different tables, so there are duplicate IDs in it. How can I only select unique IDs from this list or possibly remove duplicates?
List < userDto > list = uC.match(dto2);
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
System.out.println(list.size());
System.out.println("Data Found");
userDto dto3 = new userDto();
dto3 = uC.get(list.get(i));
System.out.println(dto3.firstName);
}
} else {
System.out.println("Data not Found");
}
I edited as below it shows the same result as List..I am new to this. I don't know whats wrong.. please help
Set<userDto> list = new HashSet<userDto>(uC.match1(dto2));
if(list.size()>0){
for (int i = 0; i < list.size(); i++) {
System.out.println(list.size());
userDto dto3=new userDto();
for (userDto s : list) {
dto3=uC.get(s);
}
System.out.println(dto3.firstName);
}
}