ComparatorUtil prevent NullPointerException

Prevention comparator null pointer exception util 



public
Final class ComparatorUtil { Private ComparatorUtil () { the throw new new AssertionError with ( "Util prohibiting reflection instantiated" ); } public static <T> int the compareTo (the Comparable <T> C1, T C2) { return c1 == null || c2 == null 0? : c1.compareTo (c2); } }

 

Guess you like

Origin www.cnblogs.com/zad27/p/11303359.html