Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Using String.toCharArray()
Use String.toCharArray() to convert a String into a char array
1
6
7
8
9
10
11
12
13
18
// {
String techioStr = "TechIO Playground";
char[] techioCharArray = techioStr.toCharArray();
for (char techioChar : techioCharArray) {
System.out.println(techioChar);
}
//{
Enter to Rename, Shift+Enter to Preview
Convert String to Char Array Using Java 8 Stream
Use .chars() to get the IntStream, and convert it to Stream Char using .mapToObj
1
6
7
8
9
10
11
16
// {
String techioStr = "TechIO Playground";
techioStr.chars() //IntStream
.mapToObj(x -> (char) x)//Stream<Character>
.forEach(System.out::println);
//{
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content