LongBuffer clear() in Java

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

Syntax:

LongBuffer java.nio.LongBuffer.clear()

This method clears this buffer.

Note: The position is set to zero, the limit is set to the capacity, and the mark is discarded.

Parameters: NA

Returns: This buffer.

Exceptions: NA

Approach

Java

import java.nio.LongBuffer;

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

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

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

Output:

java.nio.HeapLongBuffer[pos=0 lim=4 cap=4]


No comments:

Post a Comment