0
How to do a null check? Like if its in a 'if' statement. Plus what data types do support null
is default constraint available in Java?
6 Respuestas
0
if(myVar == null) {
// Throw exception? set default value? etc.
}
// Your code
_
All type that derives from the class object do.
Primitives do not. here is the list with so background to them: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
0
does this work on a double?
0
doubles can't be null, their default value is 0 except that Double type allows nulls.
0
I'm making a simple interest calc. what to do if I want that if no value is entered in time field the default is 1?
0
Double myVar = get value from user
if myVar equals null set myVar to 1
0
thanks dude!