普通青年:
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;
}
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;
}
解决方案 »
- java运行时为什么一定要进入目录中,而编译时却不需要
- 关于main(String args[])
- String中2个的format方法怎么用??我是新手,请高手指教
- Runtime.getRuntime().exec()执行错误
- JAVA中如何启动关闭WORD进程?在线等,立即结帐!!!
- 求大侠帮我给这个c++程序改成java程序 (100分重谢)
- 怎么把整型值转换成字符串型?
- 请高手解释一下这是怎么回事?
- 关于单向链表的问题。
- 紧急啊!100分相送!请问在sql server 2000中,我一个查询语句查出来的某个字段是text类型。。。。
- java socket编程 ,小妹求教,整个人都思密达了。。。
- 窗体程序运行后经常变黑!
* 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;
}
public boolean isEmpty(String s) {
if (s==null||"".equals(s)) {
return true;
}
return false;
}
空串 String str = null;
public boolean isEmpty(String s) {
if (s==null && s.length==0) {
return true;
}
return false;
}
这样是什么青年?
return (target == null || target.length() < 1) ? true : false;
}
LZ说说这个是什么青年 呵呵
public static boolean isNull(String target) {
return (target == null || target.length() < 1);
}
那你说这个算什么青年 呵呵
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
空 -- null --没有初始化isEmpty()是判断是否为空呢 还是判断空串 ? 存在二义性啊