public class TestBooleanNull {
public static void main(String[] args) {
if (test()) {
System.out.println("1232");
}
}
/**
* java.lang.Boolean是对象,可以为null。但null作为if的条件会报npe
* @return
*/
private static Boolean test() {
return null;
}
}
java.lang.Boolean为null时
阅读 153
2022-08-19
public class TestBooleanNull {
public static void main(String[] args) {
if (test()) {
System.out.println("1232");
}
}
/**
* java.lang.Boolean是对象,可以为null。但null作为if的条件会报npe
* @return
*/
private static Boolean test() {
return null;
}
}
相关推荐
精彩评论(0)