Check out example codes for "null pointer exception java". It will help you in understanding the concepts better.

Code Example 1

/**
  * @param obj An optional foo for ____. May be null, in which case 
  *  the result will be ____.
  */
public void doSomething(SomeObject obj) {
    if(obj == null) {
       //do something
    } else {
       //do something else
    }
}

Code Example 2

n=10;

Learn ReactJs, React Native from akashmittal.com