BrownTownCoder BrownTownCoder - 5 months ago 8x
Java Question

How to check a Long for null in java

How do I check a Long value for null in Java?

Will this work?

if ( longValue == null) { return blah; }


Primitive data types cannot be null. Only Object data types can be null.

int, long, etc... can't be null.

If you use Long (wrapper class for long) then you can check for null's:

Long longValue = null;

if(longValue == null)