Java Collection Tutorial - Java List.equals(Object o)








Syntax

List.equals(Object o) has the following syntax.

boolean equals(Object o)

Example

In the following code shows how to use List.equals(Object o) method.

import java.util.Arrays;
import java.util.List;
/* www  .  j  a v a2  s  .co m*/
public class Main {

  public static void main(String[] a) {

    List list = Arrays.asList(new String[] { "A", "B", "C", "D" });
    List list2 = Arrays.asList(new String[] { "A", "B", "C" });

    System.out.println(list.equals(list2));
  }
}

The code above generates the following result.