title: How to avoid checking for null values in method chaining?
body: <p>I need to check if some value is null or not. And if its not null then just set some variable to true. There is no else statement here. I got too many condition checks like this.</p>
  <p>Is there any way to handle this null checks without checking all method return values?</p>
  <pre><code>if(country != null &amp;&amp; country.getCity() != null &amp;&amp; country.getCity().getSchool() != null &amp;&amp; country.getCity().getSchool().getStudent() != null .....) {
      isValid = true;
  }
  </code></pre>
  <p>I thought about directly checking variable and ignoring <code>NullpointerException</code>. Is this a good practice?</p>
  <pre><code>try{
      if(country.getCity().getSchool().getStudent().getInfo().... != null)
  } catch(NullPointerException ex){
      //dont do anything.
  }
  </code></pre>