SyntaxFix
Write A Post
Hire A Developer
Questions
Null check in an enhanced for loop
public static <T> Iterable<T> emptyIfNull(Iterable<T> iterable) { return iterable == null ? Collections.<T>emptyList() : iterable; }
Then use:
for (Object object : emptyIfNull(someList)) { ... }