package base;
import java.util.HashMap;
import java.util.Map;
class AClass {
private Integer a;
public Integer getA() {
return a;
}
public void setA(Integer a) {
this.a = a;
}
}
public class TestAAA {
public static void main(String[] args) {
Map<String, Object> map = new HashMap<String, Object>();
AClass a = new AClass();
Integer test = map.get("d") == null ? a.getA() : 3; /// 原因是因为 a.getA()后自动拆箱 null.intValue() ,出现异常 如果改为(Integer)3 就没问题了!
System.out.println(test);
}
}