IntBuffer hashCode() in Java

hashCode(): This method is available in java.nio.IntBuffer class of Java.

Syntax:

int java.nio.IntBuffer.hashCode()

This method returns the current hash code of this buffer.

Note: The hash code of an int buffer depends only upon its remaining elements; that is, upon the elements from position() up to, and including, the element at the limit() - 1.

Parameters: NA

Returns: The current hash code of this buffer.

Exceptions: NA

Approach

Java

import java.nio.IntBuffer;

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

        int array[] = { 1, 2, 3, 4 };

        IntBuffer lb = IntBuffer.wrap(array);

        System.out.println(lb.hashCode());
    }
}

Output:

1045631


No comments:

Post a Comment