> Hi,
> can i do something like this?
>
> switch(i)
> {
> case (0<i><2):
> case (0<i><3):
> case (0<i><4):
> }
>
> Are all "cases" executed when i is 1, for example?
I am lazy to test your code in my Eclipse, but, anyway, did you already test? Just get the conclusions by yourself! Hint: I think you don磘 know what is the importance of break keyword. Do some tutorials about switch.
do you mean line:
switch(i) {
case 0:
case 1:
case 2:
// do something.
case 3:
// do something.
case 4:
// do something.
}
If i is 0,1,2 it will do all three.
After each case you should use a break statement.Otherwise all the statements should be done in order.
switch( i ) {
case 0://do staff 1
break;
case 1://do staff 2
break;
}