java use forEach for string code example
Example 1: java foreach char
for (char ch: "xyz".toCharArray()) {
System.out.println(ch);
}
Example 2: inline foreach java
names.forEach(name -> System.out.println(name));
for (char ch: "xyz".toCharArray()) {
System.out.println(ch);
}
names.forEach(name -> System.out.println(name));