String comparisions in java
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8336856/a-better-way-to-compare-strings-which-could-be-null">A better way to compare Strings which could be null</a>  </p>
</blockquote>



<p>I have an if condition which looks like this :</p>

<pre><code>if( !str1.equals(str2) )
{
    ---
    ---
    ---
}
</code></pre>

<p>where str1 and str2 are two string objects.</p>

<p>There are chances that str1 might be null , so is the below code equivalent to the above, along with handling the null check?</p>

<pre><code>if( !(str1==null ? str2==null : str1.equals(str2)) )
{
    ---
    ---
    ---
}
</code></pre>

<p>Thanks!</p>
