title: How to avoid null pointer exception in java
body: <p>I am curious to know proper way to avoid <code>NullPointerException</code>s.</p>
  
  <pre><code>try
  {
      String name = null;
      System.out.println("name=" + name.toString());
  }
  catch(Exception e)
  {
      System.out.println("Exception Occured" + e.getMessage());
  }
  </code></pre>
  
  <p>Here I am just catching and showing the exception message. I want to know proper way to handle this or avoiding such situations.</p>