if you use a non intialize variable it throws a npe code example
Example 1: nullpointerexception java
Integer num;
num = new Integer(10);
Example 2: nullpointerexception java
int x;
x = 10;
Integer num;
num = new Integer(10);
int x;
x = 10;