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

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

Comments

Popular posts from this blog

spring @async causing BeanCurrentlyInCreationException

Oracle - duplicate fields in RECORD,TABLE or argument list are not permitted