ByteBuffer remaining() in Java

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

Syntax:

int java.nio.Buffer.remaining()

This method returns the number of elements between the current position and the limit.

Parameters: NA

Returns: The number of elements remaining in this buffer.

Exceptions: NA

Approach

Java

import java.nio.ByteBuffer;

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

        byte array[] = { 1234 };
        ByteBuffer bb = ByteBuffer.wrap(array);

        System.out.println(bb.remaining());

    }
}

Output:

4

No comments:

Post a Comment