This is the snippet of code in Java language:
public void name(){
int value = 9;
int o;
if(value > 9)
o = 5;
if(value <= 9)
o = 8;
System.out.println(o);
}
Why does compiler can’t see the second if statement considering the last option of the value?
It won’t compile.
Best regards
The compiler must treat
valueas changeable unless you say otherwise. Declaring itfinalfixes the problem: