Java.util.Arrays.deepHashCode(Object[]) Method
Advertisements
Description
The java.util.Arrays.deepHashCode(Object[]) method returns a hash code based on the "deep contents" of the specified array.For any two arrays a and b such that Arrays.deepEquals(a, b), it is also the case that Arrays.deepHashCode(a) == Arrays.deepHashCode(b).
Declaration
Following is the declaration for java.util.Arrays.deepHashCode() method
public static int deepHashCode(Object[] a)
Parameters
a -- This is the array whose deep-content-based hash code to compute.
Return Value
This method returns a deep-content-based hash code for a.
Exception
- NA
Example
The following example shows the usage of java.util.Arrays.deepHashCode() method.
package com.tutorialspoint;
import java.util.Arrays;
public class ArrayDemo {
public static void main(String[] args) {
//initializing an object array
Object[] ob={ "tuts","point" };
// deephashcode for object ob
int retval=Arrays.deepHashCode(ob);
// printing value
System.out.println("The Hash Code of ob is:" + retval);
}
}
Let us compile and run the above program, this will produce the following result:
The Hash Code of ob is:217575569