2 回答

TA貢獻(xiàn)1805條經(jīng)驗 獲得超9個贊
isEmpty()方法有很多類都有,對于String類,它是Java 6.0引入的,
當(dāng)且僅當(dāng)String的length()方法返回0時返回true,否則返回false。
比如:"hello".isEmpty()就返回false,而"".isEmpty()返回true。
其他的isEmpty()方法,就像它的名字表示的那樣,判斷對象內(nèi)容是否為空,比如集合類里面是否包含元素的。列一個全的吧:
isEmpty() - 類 java.awt.geom.Arc2D.Double 中的方法
確定 RectangularShape 是否為空。
isEmpty() - 類 java.awt.geom.Arc2D.Float 中的方法
確定 RectangularShape 是否為空。
isEmpty() - 類 java.awt.geom.Area 中的方法
測試此 Area 對象是否包括其他區(qū)域。
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 未包含鍵-值映射關(guān)系,則返回 true。
isEmpty() - 類 java.beans.beancontext.BeanContextSupport 中的方法
報告此 BeanContext 是否為空。
isEmpty() - 類 java.lang.String 中的方法
當(dāng)且僅當(dāng) String.length() 為 0 時返回 true。
isEmpty() - 類 java.util.AbstractCollection 中的方法
如果此 collection 不包含元素,則返回 true。
isEmpty() - 類 java.util.AbstractMap 中的方法
如果此映射未包含鍵-值映射關(guān)系,則返回 true。
isEmpty() - 類 java.util.ArrayDeque 中的方法
如果此雙端隊列未包含任何元素,則返回 true。
isEmpty() - 類 java.util.ArrayList 中的方法
如果此列表中沒有元素,則返回 true
isEmpty() - 類 java.util.BitSet 中的方法
如果此 BitSet 中沒有包含任何設(shè)置為 true 的位,則返回 ture。
isEmpty() - 接口 java.util.Collection 中的方法
如果此 collection 不包含元素,則返回 true。
isEmpty() - 類 java.util.concurrent.ConcurrentHashMap 中的方法
如果此映射不包含鍵-值映射關(guān)系,則返回 true。
isEmpty() - 類 java.util.concurrent.ConcurrentLinkedQueue 中的方法
如果此隊列不包含任何元素,則返回 true。
isEmpty() - 類 java.util.concurrent.ConcurrentSkipListMap 中的方法
如果此映射未包含鍵-值映射關(guān)系,則返回 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 中的方法
如果此映射不包含鍵-值映射關(guān)系,則返回 true。
isEmpty() - 類 java.util.HashSet 中的方法
如果此 set 不包含任何元素,則返回 true。
isEmpty() - 類 java.util.Hashtable 中的方法
測試此哈希表是否沒有鍵映射到值。
isEmpty() - 類 java.util.IdentityHashMap 中的方法
如果此標(biāo)識哈希映射不包含鍵-值映射關(guān)系,則返回 true。
isEmpty() - 類 java.util.jar.Attributes 中的方法
如果此 Map 不包含屬性,則返回 true。
isEmpty() - 接口 java.util.List 中的方法
如果列表不包含元素,則返回 true。
isEmpty() - 接口 java.util.Map 中的方法
如果此映射未包含鍵-值映射關(guān)系,則返回 true。
isEmpty() - 接口 java.util.Set 中的方法
如果 set 不包含元素,則返回 true。
isEmpty() - 類 java.util.TreeSet 中的方法
如果此 set 不包含任何元素,則返回 true。
isEmpty() - 類 java.util.Vector 中的方法
測試此向量是否不包含組件。
isEmpty() - 類 java.util.WeakHashMap 中的方法
如果此映射不包含鍵-值映射關(guān)系,則返回 true。
isEmpty() - 類 javax.activation.MimeTypeParameterList 中的方法
確定此列表是否為空。
isEmpty() - 接口 javax.management.openmbean.TabularData 中的方法
如果此 TabularData 實例中包含的 CompositeData 值的數(shù)目(即行數(shù))為零,則返回 true。
isEmpty() - 類 javax.management.openmbean.TabularDataSupport 中的方法
如果此 TabularDataSupport 實例不包含任何行,則返回 true。
isEmpty() - 類 javax.management.timer.Timer 中的方法
測試計時器通知列表是否為空。
isEmpty() - 接口 javax.management.timer.TimerMBean 中的方法
測試計時器通知列表是否為空。
isEmpty() - 類 javax.naming.CompositeName 中的方法
確定此復(fù)合名稱是否為空。
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 中的方法
如果此映射未包含鍵-值映射關(guān)系,則返回 true。
isEmpty() - 類 javax.swing.DefaultListModel 中的方法
測試此列表中是否有組件。
isEmpty() - 類 javax.swing.text.html.parser.Element 中的方法
檢查是否為空
isEmpty() - 類 javax.swing.text.SimpleAttributeSet 中的方法
檢查屬性集是否為空。

TA貢獻(xiàn)2003條經(jīng)驗 獲得超2個贊
isEmpty(),當(dāng)字符串長度為0是,返回true,一般作為判斷,具體代碼如下:
String s = "hello" ; if (!s.isEmpty()) { // 當(dāng)s不為空時,才去做某事事情, // dosomeing } |
添加回答
舉報