Standard approach to assign default value in Java
<p>Often I invoke alien methods which might return a null value. In order to avoid simple null checks like</p>

<pre><code>if (myVariable != null) {
     // do something
}
</code></pre>

<p>I sometimes assign a default value, like this:</p>

<pre><code>myVariable = (myVariable == null) ? defaultValue : myVariable;
</code></pre>

<p>This seems a little bit redundant in Ruby for instance, there is the <code>||=</code> operator</p>

<p>I am not asking for such an operator, but my standard approach with the ternary operator seems a little bit redundant or maybe also confusing?</p>

<p>What better ways are there?</p>
