java.lang.Boolean为null时

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;
    }

}
原文地址:https://www.cnblogs.com/softidea/p/5960239.html