< prev index next >

src/java.base/share/classes/java/text/AttributedString.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD

@@ -83,11 +83,11 @@
                 appendContents(buffer, iterators[counter]);
             }
 
             text = buffer.toString();
 
-            if (text.length() > 0) {
+            if (!text.isEmpty()) {
                 // Determine the runs, creating a new run when the attributes
                 // differ.
                 int offset = 0;
                 Map<Attribute,Object> last = null;
 

@@ -142,11 +142,11 @@
         if (text == null || attributes == null) {
             throw new NullPointerException();
         }
         this.text = text;
 
-        if (text.length() == 0) {
+        if (text.isEmpty()) {
             if (attributes.isEmpty())
                 return;
             throw new IllegalArgumentException("Can't add attribute to 0-length text");
         }
 
< prev index next >