String switch | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

String switch

how can we use switch for characters? as the instructions say, switch is only for values, then what about chars?! by the way, don't forget to press the like botton.

18th Apr 2017, 4:01 PM
2 Answers
+ 9
char c='M'; switch (c){ case 'A': //stuff break; case 'N'://stuff break; default : //stuff }
18th Apr 2017, 4:05 PM
Meharban Singh
Meharban Singh - avatar
+ 5
switch can be used with strings too vihuda. along with byte,short but not long.
18th Apr 2017, 4:05 PM
Manideep - avatar