an unexpected NullPointerException in non-taken branch of tenary?
<p>I have two variables:</p>

<pre><code>final Long a;
if(...) {
     a = ...;
} else
     a = null;
String b  = "A";
....
</code></pre>

<p>and then later, assignment to another <code>Long</code> is throwing a <code>NullPointerException</code>:</p>

<pre><code>final Long c = b.equals("B")? a*1000: a;
</code></pre>

<p>I am expecting <code>c</code> to be <code>null</code> if <code>a</code> is <code>null</code>, and I'm expecting <code>b</code>, which I <em>know</em> to not be <code>B</code> in these circumstances to prevent it being dereferenced.</p>

<p>So why does it throw the <code>NullPointerException</code>?</p>

<p><em><strong>UPDATE</em></strong>: mystery solved, its auto-unboxing in the tenary operator. See <a href="http://stackoverflow.com/a/13627200/15721">http://stackoverflow.com/a/13627200/15721</a></p>
