Can i use a string in switch? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can i use a string in switch?

11th Jan 2016, 11:34 AM
Ben Wong
Ben Wong - avatar
6 Answers
+ 5
From JDK 7 onwards, you can use strings with switch statements.
16th Jan 2016, 8:13 PM
knubberkirsche
0
yes u can
13th Jun 2016, 4:29 PM
kris
0
yes..but above may be jdk version 7
22nd Jun 2016, 4:03 PM
gandhiyash
0
yes, you can, but remember to add " " to quote the value of the string and capital S
6th Jul 2016, 10:26 AM
ThisTNTSquid
ThisTNTSquid - avatar
0
yes it is possible you can add a string to a switch statement. - Ask user to input his/her gender. - Assign the gender to a variable - Pass the gender variable through the switch. statement. - if it matches any case in d switch statement. - It prints it out.
20th Oct 2016, 11:20 PM
Franky BrainBox
Franky BrainBox - avatar
- 5
no you cant
3rd Feb 2016, 11:05 AM
nitendra jaiswal