What is the statement that can be used in Java to represent a missing value of a variable. for instance I want to write a code:
if (a>=23)
income = pay_rate;
You are looking for a value, not for a statement, and that value is null
. You cannot assign null
to variables of primitive data types, such as int
and double
, but you can use it with their boxed counterparts -- Integer, Double, et cetera.
When you do that, you should be careful to check your values for null
before accessing them. Otherwise, an innocent-looking if (pay_rate > 100)
may throw a null reference exception.