- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java StringBuilder codePoints() method
The Java StringBuilder codePoints() method is, used to retrieve a stream of the code point values of characters from a StringBuilder object. The code point value of the characters is similar to the ASCII value. An ASCII value represents the numeric value for each character, such as 65 is a value of A.
The codePoints() method does not accept any parameter. It does not throw any exception while retrieving the code point value of the character from the given sequence. This methods return type is IntStream.
Note − The code point value is different for lower-case and upper-case characters.
Syntax
Following is the syntax of the Java StringBuilder codePoints() method −
public IntStream codePoints()
Parameters
It does not accept any parameter.
Return Value
This method returns an IntStream of Unicode code points from this sequence.
Example
If the given StringBuilder sequence is not null, the codePoints() method returns the code point value of the characters.
In the following program, we are instantiating the StringBuilder class with the value of HelloWorld. Then, using the codePoints() method, we are trying to retrieve the code point of the characters.
package com.tutorialspoint.StringBuilder;
import java.util.stream.IntStream;
public class CodePoint {
public static void main(String[] args) {
//instantiate the StringBuilder class
StringBuilder sb = new StringBuilder("HelloWorld");
System.out.println("StringBuilder: " + sb);
//using the codePoints() method
IntStream codepoint = sb.codePoints();
System.out.println("The code point values of characters are: ");
codepoint.forEach(System.out::println);
}
}
Output
On executing the above program, it will produce the following result −
StringBuilder: HelloWorld The code point values of characters are: 72 101 108 108 111 87 111 114 108 100
Example
In the following example, we are creating an object of the StringBuilder class with the value of Java Programming. Using the codePoints() method, we are trying to retrieve the code point value or ASCII value of the characters of this sequence.
package com.tutorialspoint.StringBuilder;
import java.util.stream.IntStream;
public class CodePoint {
public static void main(String[] args) {
//instantiate the StringBuilder class
StringBuilder sb = new StringBuilder("Java Programming");
System.out.println("StringBuilder: " + sb);
//using the codePoints() method
IntStream codepoint = sb.codePoints();
System.out.println("The code point values of characters are: ");
codepoint.forEach(codePoint_value-> System.out.print(codePoint_value + " "));
}
}
Output
Following is the output of the above program −
StringBuilder: Java Programming The code point values of characters are: 74 97 118 97 32 80 114 111 103 114 97 109 109 105 110 103