foreach in string java 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);
}