普通青年:
public boolean isEmpty(String s) {
if ("".equals(s)) {
return true;
}
return false;
}
文艺青年:
public boolean isEmpty(String s) {
if (s.length() <= 0) {
return true;
}
return false;
}
2B青年:
public boolean isEmpty(String s) {
if (s == null) {
return true;
}
return false;
}

解决方案 »

  1.   

        /**
         * Returns <tt>true</tt> if, and only if, {@link #length()} is <tt>0</tt>.
         *
         * @return <tt>true</tt> if {@link #length()} is <tt>0</tt>, otherwise
         * <tt>false</tt>
         *
         * @since 1.6
         */
        public boolean isEmpty() {
            return count == 0;
        }
      

  2.   

    字符串是否为空 用isEmpty判断不太好吧 ……
      

  3.   

    普通+2B:
    public boolean isEmpty(String s) {
            if (s==null||"".equals(s)) {
                return true;
            }
            return false;
        }
      

  4.   

    null 不是 空串。所以普通青年,2B青年的代码都错。
      

  5.   

    空字符串 String str = "";
    空串     String str = null;
      

  6.   

    null不能用equals()方法判断的,""和null不同哦。
      

  7.   

    s="";不是null是空白值
    public boolean isEmpty(String s) {
            if (s==null && s.length==0) {
                return true;
            }
            return false;
        }
    这样是什么青年?
      

  8.   

        public static boolean isNull(String target) {
            return (target == null || target.length() < 1) ? true : false;
        }
    LZ说说这个是什么青年  呵呵
      

  9.   


      public static boolean isNull(String target) {
            return (target == null || target.length() < 1);
        }
    那你说这个算什么青年 呵呵
      

  10.   

    public static boolean PTisEmpty(String s) {
            if ("".equals(s)) {
                return true;
            }
            return false;
        }
    public static boolean WYisEmpty(String s) {
            if (s.length() <= 0) {
                return true;
            }
            return false;
        }
    public static boolean ERBisEmpty(String s) {
            if (s == null) {
                return true;
            }
            return false;
        }
    public static boolean isEmpty2B(String s) {
            if (s==null||"".equals(s)) {
                return true;
            }
            return false;
        } public static boolean isEmpty3B(String s) {
      if (s==null && s.length()==0) {
      return true;
      }
      return false;
      }
    public static boolean isNull(String target) {
      return (target == null || target.length() < 1) ? true : false;
      }
    public static void main(String[] args)  {
    System.out.println(PTisEmpty(" "));
    System.out.println(WYisEmpty(" "));
    System.out.println(ERBisEmpty(" "));
    System.out.println(isEmpty2B(" "));
    System.out.println(isNull(" "));
    System.out.println(isEmpty3B(" "));
    }
    }果断全部false,BBB
      

  11.   

    空串 -- ""    --已经初始化
    空   -- null  --没有初始化isEmpty()是判断是否为空呢 还是判断空串 ? 存在二义性啊
      

  12.   

    if判断,再return true,false,你们真有才!!直接return if里面的条件不行啊