BrownTownCoder BrownTownCoder - 1 year ago 99
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; }

Answer Source

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)