Integer和基础类型比较时候会自动拆箱, null转为基础类型会报空指针异常。compare(123, null)
public static boolean compare(int a, Integer b) {
//加判空校验 int i = b == null ? 0 : b;
return a == b;//return a == i;}
记录一下,防止以后踩坑。
Integer和基础类型比较时候会自动拆箱, null转为基础类型会报空指针异常。compare(123, null)
public static boolean compare(int a, Integer b) {
//加判空校验 int i = b == null ? 0 : b;
return a == b;//return a == i;}
记录一下,防止以后踩坑。