The codePoints() method of IntStream class is used to get a stream of code point values from the given sequence. It returns the ASCII values of the characters passed as an argument
Syntax:
public IntStream codePoints()
Return Value: This method returns the IntStream code values
Below examples illustrate the use of codePoints() method:
Example 1:
import java.util.stream.IntStream;
public class GFG {
public static void main(String args[])
{
String str = "GeeksForGeeks" ;
IntStream stream = str.codePoints();
System.out.println( "ASCII Values are: " );
stream.forEach(System.out::println);
}
}
|
Output:
ASCII Values are:
71
101
101
107
115
70
111
114
71
101
101
107
115
Example 2:
import java.util.stream.IntStream;
public class GFG {
public static void main(String args[])
{
String str = "A computer science"
+ " portal for geeks" ;
IntStream stream = str.codePoints();
System.out.println( "ASCII Values are: " );
stream.forEach(System.out::println);
}
}
|
Output:
ASCII Values are:
65
32
99
111
109
112
117
116
101
114
32
115
99
105
101
110
99
101
32
112
111
114
116
97
108
32
102
111
114
32
103
101
101
107
115
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
06 Dec, 2018
Like Article
Save Article