Let's assume we have a class like this:
class Check{
private int ammount;
public Check(){
//Notice default empty builder
}
//Setters and getters
Now, how can we prevent NullPointerExceptions when calling on the getter for a primitive datatype?
//We cannot do this
...
if (myCheck.getAmmount() == null){
....
}
So, how can we prevent a NullPointerException on this cases?