IntBuffer hasArray() in Java

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

Syntax:

boolean java.nio.IntBuffer.hasArray()

This method tells whether or not this buffer is backed by an accessible int array.

Parameters: NA

Returns: true if, and only if, this buffer is backed by an array and is not read-only.

Exceptions: NA

Approach

Java

import java.nio.IntBuffer;

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

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

        IntBuffer lb = IntBuffer.wrap(array);

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

Output:

true


No comments:

Post a Comment