Java CharBuffer.length()
Syntax
CharBuffer.length() has the following syntax.
public final int length()
Example
In the following code shows how to use CharBuffer.length() method.
import java.nio.CharBuffer;
/*from ww w . j a v a2s .c o m*/
public class Main {
public static void main(String[] args) {
CharBuffer cb1 = CharBuffer.allocate(5);
cb1.put(2,'j');
cb1.rewind();
System.out.println(cb1.length());
}
}
The code above generates the following result.