Link to home
Start Free TrialLog 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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
check if this:

applianceTotal.get("Hotwater")

yields you anything. what do you expect it to get you ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanx 4 axxepting