Check out example codes for "how to use a try catch for a null pointer exception in java". It will help you in understanding the concepts better.

Code Example 1

int n;//decalred as null
n = n + 1;//null pointer exception
/////////////////////////////////////
int n = 5;
n = n + 1;//no null pointer exception

Code Example 2

n=10;

Learn ReactJs, React Native from akashmittal.com