I have the following array lists
List<Long> ids = new ArrayList<Long>();
List<Long> empIds = new ArrayList<Long>();
Now I need to compare these 2 arrays and check if any value in ids is there in empIds. If yes I need to exit with a boolean true. I have done this in the following way.
for (Long id : ids) {
if (empIds.contains(id)) {
checker = true;
break;
}
}
But this takes a lot of time. Can anybody please help me to optimize this?