+ 1

How to add condition in switch case in java ?

How to add condition in switch case in java ?

1st Aug 2019, 12:14 PM
Dexter
Dexter - avatar
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; }
1st Aug 2019, 1:57 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Can I do this Switch (a) { case (a <20 && a >10): Syso break; default: break; }
1st Aug 2019, 2:14 PM
Dexter
Dexter - avatar
+ 1
ahre del inglés
2nd Aug 2019, 11:07 PM
ET 29 5TO 7MA Morel
+ 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; }
3rd Aug 2019, 6:58 AM
Sai Ram
+ 1
Thanks Sai Ram
3rd Aug 2019, 7:06 AM
Dexter
Dexter - avatar
+ 1
switch (expression) { case n1: statements break; case n2: statements break; default: statements }
3rd Aug 2019, 5:16 PM
Dahiru Shehu Magawata
Dahiru Shehu Magawata - avatar
0
Any update on this ?
1st Aug 2019, 3:37 PM
Dexter
Dexter - avatar
3rd Aug 2019, 4:41 AM
Dexter
Dexter - avatar