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;
Option type in type theory is a way to specify type of a variable that may or may not have a meaningful value. Some languages support Option
type like Scala's scala.Option type. For languages that don't support the type you can use wrapper classes or boxed counterparts for primitives.
public class Income {
private int value;
public Income(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
...
Income income = null;
if( a >= 23)
income = new Income(pay_rate);
or simply
Integer income = null;
if( a >= 23)
income = pay_rate;