If your requirement is to maintain the insertion order plus check the contents of the two arraylist then you should do following:
List<String> listOne = new ArrayList<String>();
List<String> listTwo = new ArrayList<String>();
listOne.add("stack");
listOne.add("overflow");
listTwo.add("stack");
listTwo.add("overflow");
boolean result = Arrays.equals(listOne.toArray(),listTwo.toArray());
This will return true.
However, if you change the ordering for example:
listOne.add("stack");
listOne.add("overflow");
listTwo.add("overflow");
listTwo.add("stack");
boolean result = Arrays.equals(listOne.toArray(),listTwo.toArray());
will return false as ordering is different.