I have the primitive variable notional
of double
type:
private double notional;
Now I have to do a null
check and throw an Exception
if it is null
:
if (item.getNotional() == null) {
throw new Exception("Rfgygf");
}
But this is cannot be the correct approach since primitive types cannot be null
. Please explain how to perform a proper null
check on notional
in Java.
Is there a way to do this with a with double
or do I need to convert it into Double
?
null
value so you know itsnull
when its a specific value.... like most comonly used-1
but this in no way means it is null just sayingdouble
. Now, you want to check if it is null, but you know that it cannot be null. It simply doesn't make sense. Why should you do this? What do you mean by "if it is coming as null"?