package com.practice;
import java.util.ArrayList;
import java.util.List;
public class twoArray
{
public static void main(String[] args)
{
List<Integer> list1 = new ArrayList<>();
List<Integer> list2 = new ArrayList<>();
list1.add(00);
list1.add(01);
list1.add(02);
System.out.println(list1 +" Array list 1"); // [00,01,02] Array list 1
list2.add(01);
list2.add(02);
list2.add(00);
System.out.println(list2 +" Array list 2"); // [01,02,00] Array list 2
System.out.println(list1.equals(list2)); // output: **false**
}
}
I hope after going through this example you got an idea.
As the ArrayList internally uses the index (position) to store the values.
As per your requirements [00,01,02] and [01,02,00] the values are same and the
ordering is different and hence your using ArrayList it returns false! And it's
not equal and and you won't be able to perform any operations.
The best solution for this is you just sort both PL1 and INITIAL1
and it returns true.