Link to home
Create AccountLog in
Avatar of AndyC1000
AndyC1000

asked on

Java check not null on double

Dear all,

I'm getting a null pointer exception in the following code block.  I've read I can't check for null if its a double. How do I resolve this?

int sumHotWater = CalculateSumHotWater(hotwater_map);
double hotwater = 0;
if (sumHotWater != 0) {
    hotwater = (applianceTotal.get("Hotwater").doubleValue()); // null pointer exception here
    if (hotwater != 0.0) {
        hotwater /= sumHotWater;
    }
}

Open in new window


Thanks
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
check if this:

applianceTotal.get("Hotwater")

yields you anything. what do you expect it to get you ?
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thanx 4 axxepting