java for each string code example
Example 1: java foreach char
for (char ch: "xyz".toCharArray()) {
System.out.println(ch);
}
Example 2: for each loop string java
String s = "xyz"
for (char ch: s.toCharArray()) {
System.out.println(ch);
}
for (char ch: "xyz".toCharArray()) {
System.out.println(ch);
}
String s = "xyz"
for (char ch: s.toCharArray()) {
System.out.println(ch);
}