for each element i n string in java code example
Example 1: iterate over string java
String str = "hello";
for (char c : str.toCharArray())
//process c
Example 2: java foreach char
for (char ch: "xyz".toCharArray()) {
System.out.println(ch);
}