LongBuffer equals() in Java

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

Syntax:

boolean java.nio.LongBuffer.equals(Object ob)

This method takes one argument of type Object as its parameter. This method tells whether or not this buffer is equal to another object.

Note: A long buffer is not equal to any other type of object.

Parameters: One parameter is required for this method.

ob: The object to which this buffer is to be compared.

Returns: true if, and only if, this buffer is equal to the given object.

Exceptions: NA

Approach

Java

import java.nio.LongBuffer;

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

        long array[] = { 1, 2, 3, 4 };
        LongBuffer lb = LongBuffer.wrap(array);

        Object ob = LongBuffer.wrap(array);
        System.out.println(lb.equals(ob));
    }
}

Output:

true

No comments:

Post a Comment