Duplicate :
|
|
Relates :
|
A DESCRIPTION OF THE PROBLEM : java for-each loop throws a NullPointerException when a null collection is passed in. Instead, it should act like it does for an empty collection and just exit the loop cleanly. This would reduce a lot of boilerplate code that either has to check for null values, use Optionals, or the use of third party software (eg apache.commons).
|