ByteBuffer hasRemaining() in Java

hasRemaining(): This method is available in java.nio.ByteBuffer class of Java.

Syntax:

boolean java.nio.Buffer.hasRemaining()

This method tells whether there are any elements between the current position and the limit.

Parameters: NA

Returns: true if, and only if, there is at least one element remaining in this buffer

Approach

Java

import java.nio.ByteBuffer;

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

        byte array[] = { 1234 };
        ByteBuffer bb = ByteBuffer.wrap(array);
        System.out.println(bb.hasRemaining());

    }
}

Output:

true

No comments:

Post a Comment