2021
10-17
10-17
Java Comparator.comparing比较导致空指针异常的解决
JavaComparator.comparing比较导致空指针异常Comparator.comparing(Department::getOrder)原因:publicstatic<T,UextendsComparable<?superU>>Comparator<T>comparing(Function<?superT,?extendsU>keyExtractor){Objects.requireNonNull(keyExtractor);return(Comparator<T>&Serializable)(c1,c2)->keyExtractor.apply(c1).compareTo(keyExtractor.apply(c2));}如果key...
继续阅读 >