I’ve seen a different approach of using the FOR loop like this after create a “List” object type.
List<Focus> focuses = new ArrayList<Focus>();
String my_string = "";
for (Focus obj1 : list_obj_x) {
my_string += obj1;
}
I don’t understand how this FOR loop works in this situation.
Thanks
The enhanced for loop can be used with any object that implements
Iterable<X>and with arrays. It is equivalent to using a for loop with an iterator (in case of an iterable):It’s usage is not limited to “indexed collections” like lists and arrays.
Reference
JLS 14.14.2