Hi,
If you put the
case default: after the
case 200: statement you will get the result you desire.
The way the switch statement works is once a matching case statement is found the execution starts at that statement and
"falls through" the rest of the statements till a break is reached.
In you case it starts at
case 100: and continues to
case 200: before the conditional loop is exited.
public class SwitchTest {
public static void main(String args[]){
int test = 100;
switch(test){
case 20: System.out.println("20");
default: System.out.println("default");
case 100: System.out.println("100");
case 200: System.out.println("200"); //break;
}
}
}
Hope this helps.
------------------
Regds
Ajay Kumar
[This message has been edited by Ajay Kumar (edited June 02, 2000).]