Why can program 1 work, but program 2 cannot?
Program1:
-------------------------
public class OuterTest{
public static void main(
String args[]){
OuterTest
test = new OuterTest();
test.processBoolean(false);
}
void processBoolean(boolean flag)
{
final int x;
if (flag){
x =9;
System.out.println(x);
}
else{
x=7;
System.out.println(x);
}
}
}
program 2:
_________________________
public class OuterTest{
public static void main(String args[]){
OuterTest test = new OuterTest();
test.processBoolean(false);
}
void processBoolean(boolean flag)
{
final int x;
if (flag){
x =9;
System.out.println(x);
}
if (!flag){
x = 27;
System.out.println(x);
}
}
}