Java中将字符串(String)转换为IntStream
假设以下是我们的字符串-
String str = "My String";
现在,将以上内容转换为IntStream-
IntStream stream = str.chars();
示例
以下是在Java中将String转换为IntStream的程序-
import java.util.stream.IntStream;
public class Demo {
public static void main(String[] args) {
String str = "My String";
System.out.println("String: " + str);
IntStream stream = str.chars();
System.out.println("IntStream...");
stream.forEach(System.out::println);
}
}输出结果
String: My String IntStream... 77 121 32 83 116 114 105 110 103
热门推荐
10 祝孙辈生日祝福语简短
11 恋人跨年祝福语大全简短
12 考大学敬酒简短祝福语
13 开工投产大吉祝福语 简短
14 偶然结婚祝福语朋友简短
15 感谢学长学姐祝福语简短
16 戏精的祝福语简短
17 我要结婚祝福语简短
18 婚前女儿生日祝福语简短