Best practise to handle Exception in thread "main" java.lang.NullPointerException from Bean class : <p>Am using Bean class to get/set value for the attributes. In some cases am gettig <code>Exception in thread "main" java.lang.NullPointerException</code> error due to the value is null. What will be the best practice to handle null pointer exception when we get/set values from/to bean class.</p>

<p>Is that ternary operator is good to use or any other suggestions?</p>

<p>Please find the below line of code where am getting null pointer exception.</p>

<pre><code>doc.setCatalog_title(sourceAsMap.get("catalog_title").toString());
</code></pre>
