0
点赞
收藏
分享

微信扫一扫

java.lang.Boolean为null时

司马吹风 2022-08-19 阅读 153

 

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 条评论