The length() method of java.nio.CharBuffer Class is used to return the length of this character buffer. When viewed as a character sequence, the length of a character buffer is simply the number of characters between the position (inclusive) and the limit (exclusive); that is, it is equivalent to remaining().
public final int length()
Return Value: This method returns the length of this character buffer.
Below are the examples to illustrate the length() method:
CharBuffer is : [a, b, c] Length: 3
CharBuffer before append : [a, b,, ] Length: 2 CharBuffer after append : [a, b, c, ] Length: 1
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.