LongBuffer clear() method in Java with Examples
The clear() method of java.nio.LongBuffer Class is used to clear this buffer. While clearing this buffer following changes are done:
- the position is set to zero
- the limit is set to the capacity
- the mark is discarded.
public final LongBuffer clear()
Parameter: The method do not take any parameter.
Return Value: This method returns this LongBuffer instance after clearing all the data from it.
Below are the examples to illustrate the clear() method:
position before reset: 4 position after reset: 0
position before clear: 3 position after clear: 0
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.