0
点赞
收藏
分享

微信扫一扫

Java 空值判断

   // 公共方法
   public static boolean isNull(Object o) {
        boolean isNull = false;
        if (null == o || o.toString().isEmpty() || "null".equalsIgnoreCase(o.toString())) {
            isNull = true;
        }

        return isNull;
    }
    
   // 方法调用
    if (!isNull(aa)) {
         System.out.println("内容不为空!");
        }else{
         System.out.println("内容为空!");
        }

举报

相关推荐

0 条评论