I have two list (listA and listB) and I want them to be independent. So I can add an element to the listB without the elements of the listA being modified, to remain the same.
Tryed Collection listB = Collections.unmodifiableCollection(listA);
    ArrayList<String> listA = new ArrayList<>();
    listA.add("alex");
    listA.add("brian");
    listA.add("charles");
    ArrayList<String> listB = new ArrayList<>();
    listB = listA;
    listB.add("williams");
    System.out.println(listA);
run: [alex, brian, charles, williams]
When I run it I wanted to show only theese
run:
[alex, brian, charles]
(Without "williams")
 
     
     
     
     
     
    