switch/case question

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?
[225 byte] By [uiga] at [2007-10-2 5:47:23]
# 1

> 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.

Marcelo9a at 2007-7-16 1:57:00 > top of Java-index,Java Essentials,Java Programming...
# 2

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.

Peter-Lawreya at 2007-7-16 1:57:00 > top of Java-index,Java Essentials,Java Programming...
# 3

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;

}

Vanibasa at 2007-7-16 1:57:00 > top of Java-index,Java Essentials,Java Programming...