Clicky

Java 8 - Avoid null pointer exception while calling a null list, set or array of objects

June 24, 2016

StringBuilder sb = new StringBuilder();
ofNullable(category).orElse(new LinkedList<>()).forEach(a->sb.append(a.toString()));