posted 20 years ago
Hi jk,
In your code u r reassigning the value of te as false.
general form of if() else construct is:
if(true){
//do something;} // line 1
else{
//do some other thing //line 2
}
i.e. if if the condition checked in if() is true then line 1 will be executed ,otherwise the else part will be executed.
so, in ur code first the value of te is changed to false and then the condition is evaluated.
since now te is false, the else part is executed.
if u change ur code in this way it may be clear for u:
boolean te = false;
if(te = true){ // line A
System.out.println("true");
}
else{
System.out.println("False");
}
here at line a, u r assigining true to te .so, now the condition evaluates to true and hence prints true.
vineela