Scenario Imagine we have a List of Strings. We will do a very simple task — print out each element in that string. The intuitive code that comes to mind might be this : final List<String> strings = Arrays.asList("str1", "str2", "str3", "str4", "str5");
int i;
for (i=0; i < strings.size(); i++){…