you posted:
p s v main (S ar[]){
boolean x = true;
int a;
if(x) a=x? 1:2;
else a=x? 3:4;
System.out.println(a);
}
=====
even though a is not initialized ,as you are not fetching the value of a , it compiles AND at runtime when the Statemnt assigns 1 to a , it does not check whats the previous value is ,ruther simply reWrites .
BUT if you
test as follows ,
public static void main(String[] args)
{
boolean x = true;
int a;
System.out.println(a);
if(x) a=x? 1:2;
else a=x? 3:4;
}
compiler complains " a has not been init " .