0
Can i use a string in switch?
6 Answers
+ 5
From JDK 7 onwards, you can use strings with switch statements.
0
yes u can
0
yes..but above may be jdk version 7
0
yes, you can, but remember to add " " to quote the value of the string and capital S
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.
- 5
no you cant