title: How to check if my string is equal to null?
body: <p>I want to perform some action ONLY IF my string has a meaningful value. So, I tried this.</p>
  
  <pre><code>if (!myString.equals("")) {
  doSomething
  }
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>if (!myString.equals(null)) {
  doSomething
  }
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>if ( (!myString.equals("")) &amp;&amp; (!myString.equals(null))) {
  doSomething
  }
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>if ( (!myString.equals("")) &amp;&amp; (myString!=null)) {
  doSomething
  }
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>if ( myString.length()&gt;0) {
  doSomething
  }
  </code></pre>
  
  <p>And in all cases my program <code>doSomething</code> in spite on the fact that my string IS EMPTY. It equals to <code>null</code>. So, what is wrong with that?</p>
  
  <p><strong>ADDED:</strong></p>
  
  <p>I found the reason of the problem. The variable was declared as a string and, as a consequence, <code>null</code> assigned to this variable was transformed to <code>"null"</code>! So, <code>if (!myString.equals("null"))</code> works.</p>