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

}

 

相关文章:

  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-05-23
  • 2021-05-23
猜你喜欢
  • 2021-07-16
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案