IntBuffer equals(Object) in Java

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

Syntax:

boolean java.nio.IntBuffer.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 int 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.IntBuffer;

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

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

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

Output:

true


No comments:

Post a Comment