If you try and cast null
to an int
, you will get a NullPointerException
.
If you want to null-check it, you can use an Integer
or Object
variable.
Integer r = (Integer) map.get("some_integer");
if (r==null) {
// whatever you want to do in this case
} else {
int result = r;
// whatever you want to do with the result
}
solved Checking int cast from null