The codePoints() method in Java IntStream


The codePoint() method is used to display a stream of code point values from the given sequence.

The syntax is as follows

IntStream codePoints()

To work with Java IntStream class, you need to import the following package

import java.util.stream.IntStream;

Here is our string

String myStr = "Example!";

Now, get the code point values

IntStream intStream = myStr.codePoints();

The following is an example to implement codePoints() method in Java IntStream

Example

 Live Demo

import java.util.stream.IntStream;
public class Demo {
   public static void main(String args[]) {
      String myStr = "Example!";
      IntStream intStream = myStr.codePoints();
      System.out.println("The following is the list of ASCII Values for the given string = ");
      intStream.forEach(System.out::println);
   }
}

Output

The following is the list of ASCII Values for the given string =
69
120
97
109
112
108
101
33

Updated on: 30-Jul-2019

324 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements