Java IntStream中的codePoints()方法
该codePoint()方法用于显示给定序列中的代码点值流。
语法如下
IntStream codePoints()
要使用JavaIntStream类,您需要导入以下包
import java.util.stream.IntStream;
这是我们的弦
String myStr = "Example!";
现在,获取代码点值
IntStream intStream = myStr.codePoints();
以下是codePoints()在JavaIntStream中实现方法的示例
示例
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);
}
}输出结果
The following is the list of ASCII Values for the given string = 69 120 97 109 112 108 101 33