Checking of presence of a value in nullable types in Java
Forums:
Integer n1 = 42;
boolean exists1 = n1 != null;
//exists1 is true
Integer n2 = null;
boolean exists2 = n2 != null;
//exists2 is false
- Log in to post comments
Integer n1 = 42;
boolean exists1 = n1 != null;
//exists1 is true
Integer n2 = null;
boolean exists2 = n2 != null;
//exists2 is false