/**
* Returns k.compareTo(x) if x matches kc (k's screened comparable
* class), else 0.
* 如果x的类型是kc,返回k.compareTo(x)的比较结果
* 如果x为空,或者类型不是kc,返回0
*/
@SuppressWarnings({"rawtypes","unchecked"}) // for cast to Comparable
static int compareComparables(Class<?> kc, Object k, Object x) {
return (x == null || x.getClass() != kc ? 0 :
((Comparable)k).compareTo(x));
}
jdk1.8 hashmap.compareComparables方法解析
最新推荐文章于 2021-12-09 22:41:51 发布