I have this “helper” class that contains a number of values taken from the server, for example:
public boolean getSettings1(){
return (Boolean) user.getProperty("settings1");
}
Which I then use to check against like:
if(prefs.getSettings1()){
//Do stuff
}
However, I’ve set this boolean’s default value to “false” in my console. Yet I get a nullpointer exception when checking that value. And I do have a logged in user for sure since I can receive a userID with no exceptions . So what may I be doing wrong here?
Am I using the wrong datatype? When I try returning Boolean instead of boolean I can atleast check if it’s null and get around this problem, but it’s not a solution I would like to fall back to.
The error is: by: java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean java.lang.Boolean.booleanValue()’ on a null object reference