Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think <code>isEmpty()</code> is a bit more efficient. However a smart compiler may optimize the <code>equals("")</code> call anyway. From the <a href="http://hg.openjdk.java.net/jdk7/build-gate/jdk/file/tip/src/share/classes/java/lang/String.java" rel="nofollow noreferrer">OpenJDK source</a>:</p> <pre><code> 671 public boolean isEmpty() { 672 return count == 0; 673 } 1013 public boolean equals(Object anObject) { 1014 if (this == anObject) { 1015 return true; 1016 } 1017 if (anObject instanceof String) { 1018 String anotherString = (String)anObject; 1019 int n = count; 1020 if (n == anotherString.count) { 1021 char v1[] = value; 1022 char v2[] = anotherString.value; 1023 int i = offset; 1024 int j = anotherString.offset; 1025 while (n-- != 0) { 1026 if (v1[i++] != v2[j++]) 1027 return false; 1028 } 1029 return true; 1030 } 1031 } 1032 return false; 1033 } </code></pre> <p>Also the <a href="https://stackoverflow.com/questions/3321526/should-i-use-string-isempty-or-equalsstring/3321548#3321548">answer here</a> on whether to use <code>str.isEmpty()</code> or <code>"".equals(str)</code> is spot on:</p> <blockquote> <p>The main benefit of <code>"".equals(s)</code> is you don't <em>need</em> the null check (<code>equals</code> will check its argument and return <code>false</code> if it's null), which you seem to not care about. If you're not worried about <code>s</code> being null (or are otherwise checking for it), I would definitely use <code>s.isEmpty()</code>; it shows exactly what you're checking, you care whether or not <code>s</code> is empty, not whether it equals the empty string</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload