使用isEmpty()时出错 [英] error in use of isEmpty()

查看:297
本文介绍了使用isEmpty()时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试检查条件!String_value.isEmpty().当我使用它的时候显示
错误消息,如:运算符!不能应用于java.lang.string.isEmpty

例如

如果(!value.isEmpty())
{
声明;

}

请帮帮我..

问候
sasi



i am trying to check a condition !String_value.isEmpty(). when i am using this its showing
error message like: operator ! cannot be applied to java.lang.string.isEmpty

for example

if (!value.isEmpty())
{
statement;

}

pls help me..

regards
sasi

推荐答案

以下代码段可在我的系统上编译并正常运行
the following code snippet compiles and runs fine on my system
class foo
{
	public static void main(String args[])
	{
		String value ="foo";
		if (!value.isEmpty())
		{
			System.out.println(value);	
		}
	}
}


您的值是什么类型?

What type is your value?

String myString = "";
if (!myString.isEmpty()) {
    System.out.print("It's not empty");
}



工作正常,可以显示更多代码吗?

/Fredrik



Works fine, can you show more of your code?

/Fredrik


首先,我认为您键入了问题,而不是在真正的错误消息和/或代码上使用粘贴".您正在使用的字符串类型是java.lang.String,而不是java.lang.string.我现在不知道您的代码中到底有什么.

其次,我将Java平台SE 6与Java平台SE 6进行了比较.方法java.lang.string isEmpty()仅在Java平台SE 6中可用.问题可能出在您使用的平台的版本上.
请自己比较:
http://download.oracle.com/javase/1,5.0/docs/api/java/lang/String.html [ ^ ],
http://download.oracle.com/javase/6/docs/api/java/lang/String.html [ ^ ].

—SA
First of all, I think you typed the question instead of using "Paste" on real error message and/or code. The string type you''re using is java.lang.String, not java.lang.string. I don''t know what is really in your code now.

Secondly, I compared Java platform SE 6 with Java platform SE 6. The method java.lang.string isEmpty() is only available in Java platform SE 6. The problem could be a version of the platform you use.

Please compare by yourself:
http://download.oracle.com/javase/1,5.0/docs/api/java/lang/String.html[^],
http://download.oracle.com/javase/6/docs/api/java/lang/String.html[^].

—SA


这篇关于使用isEmpty()时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆