LongBuffer hashCode() in Java

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

Syntax:

int java.nio.LongBuffer.hashCode()

This method returns the current hash code of this buffer.

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

Parameters: NA

Returns: The current hash code of this buffer.

Exceptions: NA

Approach

Java

import java.nio.LongBuffer;

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

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

        LongBuffer lb = LongBuffer.wrap(array);

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

Output:

1045631


No comments:

Post a Comment