java check if variable is set

Java
if (x == 0) { // only allow setting if x has its initial value
    x = somenewvalue;
}
Source

Also in Java: