+ 1
How to add condition in switch case in java ?
How to add condition in switch case in java ?
9 Respuestas
+ 8
switch (reference){
case (something):
do stuff;
break; //recommended to prevent screwups but depends in what code you make
default:
if all else fails do this;
break;
}
+ 1
Can I do this
Switch (a)
{
case (a <20 && a >10):
Syso
break;
default:
break;
}
+ 1
ahre del inglés
+ 1
vishal Cool
you cannot use the above code.
try this
datatype a;
switch(x)
{
case 1:
if(a<20&&a>10)
syso;
break;
case 2:
if(...)
........
break;
default:
.........
break;
}
+ 1
Thanks Sai Ram
+ 1
switch (expression) {
case n1:
statements
break;
case n2:
statements
break;
default:
statements
}
0
Any update on this ?
0
Victoria Morel what ?