Prevent null check before collection.add
Instead of
if (o != null) {
collection.add(o);
}
write
collection.add(o);
collection.removeAll(asList((String) null));
Written by quartzde
Related protips
2 Responses
It may depends on the situation. I still prefer the first on game dev as it'll be faster.
over 1 year ago
·
Why you don't create your own collection with this logic?
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Collections
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#