Java Collection Tutorial - Java List.hashCode()








Syntax

List.hashCode() has the following syntax.

int hashCode()

Example

In the following code shows how to use List.hashCode() method.

//w w  w. j a v a2  s .c  om
import java.util.Arrays;
import java.util.List;
public class Main {
  public static void main(String[] a) {
    List list = Arrays.asList(new String[] { "A", "B", "C", "D" });
    System.out.println(list.size());
    System.out.println(list.hashCode());
  }
}

The code above generates the following result.