Java 8 Iterable.forEach() vs foreach loop
The better practice is to use for-each. Besides violating the Keep It Simple, Stupid principle, the new-fangled forEach() has at least the following deficiencies: Can’t use non-final variables. So, code like the following can’t be turned into a forEach lambda: Object prev = null; for(Object curr : list) { if( prev != null ) foo(prev, … Read more