Open In App

DoubleBuffer clear() methods in Java with Examples

Last Updated : 29 Jul, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The clear() method of java.nio.CharBuffer 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.
Syntax:
public final DoubleBuffer clear()
Return Value: This method returns this DoubleBuffer instance after clearing all the data from it. Below are the examples to illustrate the clear() method: Examples 1:
Output:
position before reset: 4
position after reset: 0
Examples 2:
Output:
position before clear: 3
position after clear: 0
Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/DoubleBuffer.html#clear--

Practice Tags :

Similar Reads