if you use a non initialized variable it throws an 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;