List<Integer> list1 = Arrays.asList(1, 2, 3, 3);
List<Integer> list2 = Arrays.asList(3, 1, 2, 2);
System.out.println(list1.isEquals(list2));
上面会认为是元素相同,个数相同,但实际上明显不是严格的相等了,最好是用apache common包:
List<Integer> list1 = Arrays.asList(1, 2, 3, 3);
List<Integer> list2 = Arrays.asList(3, 1, 3, 2);
System.out.println(CollectionUtils.isEqualCollection(list1, list2)); //true