Free Version

Upgrade subject to access all content

Easy

Using a For-Each Loop to Simplify Array Manipulations

ALGOR-$Q5EY0

The following code sample uses a for-each loop to manipulate the values in an array of Strings:

String[] strings = {"hotel", "oscar", "whiskey", "delta", "yankee"};
String mystery = "";

for(String s : strings) {
   mystery += s.charAt(0);
}

System.out.print(mystery);