I have Three List and in the third list i'm merging two list. if i make changes in third why the change gets reflect to other list and how to overcome?
List<Communication> communicationFromList = fromTicket.getCommunications();
List<Communication> communicationToList = toTicket.getCommunications();
List<Communication> mergedCommunication=new ArrayList<>();
mergedCommunication.addAll(communicationToList);
mergedCommunication.addAll(communicationFromList);
for (int i = index; i < mergedCommunication.size(); i++) {
if (!ObjectUtils.isEmpty(mergedCommunication.get(i))) {
int j =i;
Communication communication = mergedCommunication.get(i);
communication.setCommSeqId(++j);
communication.setMergeInfo("Merged From: " + fromTicketId);
}
}
Due Above changes gets reflect over to other list also.how to overcome