Java Collection Tutorial - Java Arrays.hashCode(char[] a)








Syntax

Arrays.hashCode(char[] a) has the following syntax.

public static int hashCode(char[] a)

Example

In the following code shows how to use Arrays.hashCode(char[] a) method.

/* w w w  .  ja v a 2 s . c  o m*/
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
   
    // initializing char array
    char[] cval = new char[] { 'a', 'k' };

    System.out.println(Arrays.hashCode(cval));
    System.out.println(cval.hashCode());
  }
}

The code above generates the following result.