Compilation error on ternary operator on Strings
<p>I am simply trying to handle <code>null</code>   <code>String</code> concatenation with below syntax and both are not compiling - <code>Invalid Assignment Operator</code>  and <code>Type Mismacth: can not convert fron null to boolean</code></p>

<pre><code>String claimId = String.valueOf(VO.getClaimId());
StringBuffer strBuffer = new StringBuffer();
claimId == null?strBuffer.append(""):strBuffer.append(claimId);
</code></pre>

<p>OR</p>

<pre><code>String claimId = String.valueOf(VO.getClaimId());
StringBuffer strBuffer = new StringBuffer();
(claimId == null)?strBuffer.append(""):strBuffer.append(claimId);
</code></pre>

<p>I simply want to append empty string if <code>claimId</code> String is null and append <code>claimId</code> otherwise. </p>

<p>What works is like, </p>

<pre><code>String tempClaimId = (claimId == null)?"":claimId;
</code></pre>

<p>Later I can append <code>tempClaimId</code> to <code>strBuffer</code> </p>

<p>is Assignment expression mandatory here? Can't ternary operator syntax just be used to call methods?</p>

<p>How can I handle calling <code>append</code> with ternary without creating temporary Strings? OR do I just use <code>if-else</code>. </p>