Code below checks if duplicate items exist in two lists composed of HashMaps. In which part of the code can throw an exception and how I should handle it?
ArrayList<HashMap<String, String>> mapList1 = new ArrayList<>();
ArrayList<HashMap<String, String>> mapList2 = new ArrayList<>();
//remove duplicate entries
for (int i = 0; i < mapList1.size(); i++) {
for (int j = 0; j < mapList2.size(); j++) {
if (mapList1.get(i).get("id").equals(mapList2.get(i).get("id"))) {
mapList1.remove(i);
break;
}
}
}