The ArrayList
class inherits its equals()
method from the AbstractList
class:
An ArrayList is equal to another object if
size()
import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] a) { List<String> list = Arrays.asList(new String[] { "CSS", "Binary", "C++", "Dart" }); List<String> list2 = Arrays.asList(new String[] { "CSS", "Binary", "C++" }); System.out.println(list.equals(list2)); }/*from w ww .ja v a2s.com*/ }