Java isEmpty()未定义为String? [英] Java isEmpty() undefined for String?

查看:236
本文介绍了Java isEmpty()未定义为String?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在eclipse中的一个学校项目上工作,当我尝试使用 isEmpty()方法在一个 String ,Eclipse显示以下错误:


方法isEmpty()未定义为类型String


我已经运行Java更新,但仍然得到它。是否有任何原因导致此方法未定义?

解决方案

String.isEmpty()已添加到


I'm working on a school project in eclipse, and when I try and use the isEmpty() method on a String, Eclipse shows up the following error:

The method isEmpty() is undefined for the type String

I've run the Java updates, but am still getting it. Is any reason why this method would be undefined?

解决方案

String.isEmpty() was added in Java 6. In earlier versions you can use StringUtils.isEmpty(String) from Apache's commons-lang library.

To configure Eclipse to use the 1.6 JRE, go to Window->Preferences->Java->Installed JREs. If you haven't already got JAva 1.6 configured, select Add...,browse to your 1.6 installation and add it.

configure JREs screenshot http://www.lumidant.com/blog/wp-content/uploads/2008/01/eclipse_edit_jre.png

这篇关于Java isEmpty()未定义为String?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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