Java中isEmpty方法如何使用?

isEmpty在Java1.?中有的?

isEmpty()方法有很多类都有,对于String类,它是Java 6.0引入的,
当且仅当String的length()方法返回0时返回true,否则返回false。
比如:"hello".isEmpty()就返回false,而"".isEmpty()返回true。

其他的isEmpty()方法,就像它的名字表示的那样,判断对象内容是否为空,比如集合类里面是否包含元素的。列一个全的吧:

isEmpty() - 类 java.awt.geom.Arc2D.Double 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.geom.Arc2D.Float 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.geom.Area 中的方法
测试此 Area 对象是否包括其他区域。
isEmpty() - 类 java.awt.geom.Ellipse2D.Double 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.geom.Ellipse2D.Float 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.geom.Rectangle2D.Double 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.geom.Rectangle2D.Float 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.geom.RectangularShape 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.geom.RoundRectangle2D.Double 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.geom.RoundRectangle2D.Float 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.Rectangle 中的方法
确定 RectangularShape 是否为空。
isEmpty() - 类 java.awt.RenderingHints 中的方法
如果此 RenderingHints 未包含键-值映射关系,则返回 true。
isEmpty() - 类 java.beans.beancontext.BeanContextSupport 中的方法
报告此 BeanContext 是否为空。
isEmpty() - 类 java.lang.String 中的方法
当且仅当 String.length() 为 0 时返回 true。
isEmpty() - 类 java.util.AbstractCollection 中的方法
如果此 collection 不包含元素,则返回 true。
isEmpty() - 类 java.util.AbstractMap 中的方法
如果此映射未包含键-值映射关系,则返回 true。
isEmpty() - 类 java.util.ArrayDeque 中的方法
如果此双端队列未包含任何元素,则返回 true。
isEmpty() - 类 java.util.ArrayList 中的方法
如果此列表中没有元素,则返回 true
isEmpty() - 类 java.util.BitSet 中的方法
如果此 BitSet 中没有包含任何设置为 true 的位,则返回 ture。
isEmpty() - 接口 java.util.Collection 中的方法
如果此 collection 不包含元素,则返回 true。
isEmpty() - 类 java.util.concurrent.ConcurrentHashMap 中的方法
如果此映射不包含键-值映射关系,则返回 true。
isEmpty() - 类 java.util.concurrent.ConcurrentLinkedQueue 中的方法
如果此队列不包含任何元素,则返回 true。
isEmpty() - 类 java.util.concurrent.ConcurrentSkipListMap 中的方法
如果此映射未包含键-值映射关系,则返回 true。
isEmpty() - 类 java.util.concurrent.ConcurrentSkipListSet 中的方法
如果此 set 不包含任何元素,则返回 true。
isEmpty() - 类 java.util.concurrent.CopyOnWriteArrayList 中的方法
如果此列表不包含任何元素,则返回 true。
isEmpty() - 类 java.util.concurrent.CopyOnWriteArraySet 中的方法
如果此 set 不包含任何元素,则返回 true。
isEmpty() - 类 java.util.concurrent.SynchronousQueue 中的方法
始终返回 true。
isEmpty() - 类 java.util.Dictionary 中的方法
测试此 dictionary 是否不存在从键到值的映射。
isEmpty() - 类 java.util.HashMap 中的方法
如果此映射不包含键-值映射关系,则返回 true。
isEmpty() - 类 java.util.HashSet 中的方法
如果此 set 不包含任何元素,则返回 true。
isEmpty() - 类 java.util.Hashtable 中的方法
测试此哈希表是否没有键映射到值。
isEmpty() - 类 java.util.IdentityHashMap 中的方法
如果此标识哈希映射不包含键-值映射关系,则返回 true。
isEmpty() - 类 java.util.jar.Attributes 中的方法
如果此 Map 不包含属性,则返回 true。
isEmpty() - 接口 java.util.List 中的方法
如果列表不包含元素,则返回 true。
isEmpty() - 接口 java.util.Map 中的方法
如果此映射未包含键-值映射关系,则返回 true。
isEmpty() - 接口 java.util.Set 中的方法
如果 set 不包含元素,则返回 true。
isEmpty() - 类 java.util.TreeSet 中的方法
如果此 set 不包含任何元素,则返回 true。
isEmpty() - 类 java.util.Vector 中的方法
测试此向量是否不包含组件。
isEmpty() - 类 java.util.WeakHashMap 中的方法
如果此映射不包含键-值映射关系,则返回 true。
isEmpty() - 类 javax.activation.MimeTypeParameterList 中的方法
确定此列表是否为空。
isEmpty() - 接口 javax.management.openmbean.TabularData 中的方法
如果此 TabularData 实例中包含的 CompositeData 值的数目(即行数)为零,则返回 true。
isEmpty() - 类 javax.management.openmbean.TabularDataSupport 中的方法
如果此 TabularDataSupport 实例不包含任何行,则返回 true。
isEmpty() - 类 javax.management.timer.Timer 中的方法
测试计时器通知列表是否为空。
isEmpty() - 接口 javax.management.timer.TimerMBean 中的方法
测试计时器通知列表是否为空。
isEmpty() - 类 javax.naming.CompositeName 中的方法
确定此复合名称是否为空。
isEmpty() - 类 javax.naming.CompoundName 中的方法
确定此组合名称是否为空。
isEmpty() - 类 javax.naming.ldap.LdapName 中的方法
确定此 LDAP 名称是否为空。
isEmpty() - 接口 javax.naming.Name 中的方法
确定此名称是否为空。
isEmpty() - 接口 javax.print.attribute.AttributeSet 中的方法
如果此属性集不包含任何属性,则返回 true。
isEmpty() - 类 javax.print.attribute.HashAttributeSet 中的方法
如果此属性集不包含任何属性,则返回 true。
isEmpty() - 类 javax.script.SimpleBindings 中的方法
如果此映射未包含键-值映射关系,则返回 true。
isEmpty() - 类 javax.swing.DefaultListModel 中的方法
测试此列表中是否有组件。
isEmpty() - 类 javax.swing.text.html.parser.Element 中的方法
检查是否为空
isEmpty() - 类 javax.swing.text.SimpleAttributeSet 中的方法
检查属性集是否为空。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-10-10

isEmpty(),当字符串长度为0是,返回true,一般作为判断,具体代码如下:

String s = "hello";
if(!s.isEmpty()) {// 当s不为空时,才去做某事事情,
    // dosomeing
}

第2个回答  2015-09-24
是map的isEmpty()方法?
相似回答