compare two strings in Java with possible null values
<p>I know this question has been asked several times with different flavors.  But couldn't find related to this one.  I can write complex if condition with <code>3 ands</code>, but I want to check out the best possible solution.</p>

<pre><code>bool compare (String str1, String str2) {

 }
</code></pre>

<p>str1, str2 can be null, so i cannot use <code>.equals()</code>.</p>

<p>Edit: 
return ((str1 == str2) || (str1 != null &amp;&amp; str1.equals(str2)));</p>
