CharBuffer chars() methods in Java with Examples
The chars() method of java.nio.CharBuffer Class is used to return a stream of int zero-extending the char values from this sequence. Any char which maps to a surrogate code point is passed through uninterpreted. The stream binds to this sequence when the terminal stream operation commences (specifically, for mutable sequences the spliterator for the stream is late-binding). If the sequence is modified during that operation then the result is undefined.
public IntStream chars()
Return Value: This method returns an IntStream of char values from this sequence.
Below are the examples to illustrate the chars() method:
Original CharBuffer: [a, b, c] 97 98 99
Original CharBuffer: [?, u, v, , Z] 140 117 118 0 90
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.