![]() |
VOOZH | about |
In Java, the chars() method of the StringBuffer class converts the characters in the StringBuffer to an IntStream. This method is useful for iterating over, processing, or filtering characters in a StringBuffer.
Example 1: Here, we will iterate over characters by using the chars() method and it will print the Unicode code points of each character in a StringBuffer object.
74 97 118 97
chars() MethodIntStream chars()
Example 2: Here, we will use the chars() method to process numeric characters in the StringBuffer.
1 2 3 4 5
Example 3: Here, we will use the chars() method with a StringBuffer containing both letters and digits.
115 119 101 50 49 55 97 109 105