Friday, May 30, 2014

How to do null-safe Integer comparison in Java

result = ObjectUtils.compare(firstComparable, secondComparable)
commons-lang3 has a useful null-safe compare method between two Comparables. This comes in-handy for non-primitives like Integer, Long, Boolean, etc.

12 comments: