Arrays.deepHashCode(Object[]) in Java

Arrays.deepHashCode(Object[]): This method is available in java.util.Arrays class of Java.

Syntax:

int java.util.Arrays.deepHashCode(Object[] a)

This method takes one argument of type Object array as its parameter. This method returns a hash code based on the "deep contents" of the specified array. If the array contains other arrays as elements, the hash code is based on their contents and so on, ad infinitum.

Parameters: One parameter is required for this method.

a: the array whose deep-content-based hash code to compute.

Returns: a deep-content-based hash code for a.

Exceptions: NA

Approach

Java

import java.util.Arrays;

public class ArraysdeepHashCode {
    public static void main(String[] args) {

        Object a1[] = { 'a', 'b', 'c', 'd' };

        System.out.println(Arrays.deepHashCode(a1));
    }
}

Output:

3910595


No comments:

Post a Comment