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:
// Java program to demonstrate // codePoints() method of IntStream class import java.util.stream.IntStream; public class GFG { public static void main(String args[]) { // String to be converted String str = "GeeksForGeeks"; // Convert the string to code values // using codePoints() method IntStream stream = str.codePoints(); System.out.println("ASCII Values are: "); // Print the code points stream.forEach(System.out::println); } } |
ASCII Values are: 71 101 101 107 115 70 111 114 71 101 101 107 115
Example 2:
// Java program to demonstrate // codePoints() method of IntStream class import java.util.stream.IntStream; public class GFG { public static void main(String args[]) { // String to be converted String str = "A computer science" + " portal for geeks"; // Convert the string to code values // using codePoints() method IntStream stream = str.codePoints(); System.out.println("ASCII Values are: "); // Print the code points stream.forEach(System.out::println); } } |
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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- IntStream max() in Java with examples
- IntStream min() in Java with Examples
- IntStream distinct() in Java with examples
- IntStream filter() in Java with examples
- IntStream anyMatch() in Java with examples
- IntStream allMatch() in Java with examples
- IntStream empty() in Java with examples
- IntStream peek() in Java with examples
- IntStream average() in Java with Examples
- IntStream count() in Java with examples
- IntStream toArray() in Java with Examples
- IntStream noneMatch() in Java with examples
- IntStream.Builder build() in Java with Examples
- IntStream reduce(IntBinaryOperator op) in Java with Examples
- IntStream reduce(int identity, IntBinaryOperator op) in Java with Examples
- IntStream forEach() method in Java
- IntStream forEachOrdered() method in Java
- IntStream generate() method in Java
- IntStream.Builder add() method in Java
- IntStream.Builder accept() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

