Let's say I have an arrayList1 of Points. The data structure is like this :
(1,2)->(2,2)->(3,2)->(4,2)->(5,2)
I have another arrayList2 of Points :
(2,2)->(1,2)->(8,5)->(9,3)
How do I compare the two lists and add non-existing values from arrayList2 to arrayList1?
current solution
The only method I can think of now is using a for loop to compare each of the Points in arrayList1 such as, if(!arrayList1.contains(arrayList2.get(i))){ arrayList1.add(arrayList2.get(i)); } i++;
.
Is there a more efficient way or already prepared method from a class? Because I have arrayList1 until arrayList6 to compare and replace....