0
How to use string in switch in java?
Please answer my question, I am new to programming.
5 Answers
+ 4
You can see my example code. Hope it helps you.
https://code.sololearn.com/cJxcwS9gIAS5/?ref=app
+ 6
zemiak, true
Now in Java 12 this is possible
switch (day) {
case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);
case TUESDAY -> System.out.println(7);
case THURSDAY, SATURDAY -> System.out.println(8);
case WEDNESDAY -> System.out.println(9);
}
https://hackernoon.com/announcement-java12-has-released-435e659affee
https://dzone.com/articles/jdk-12-switch-statementsexpressions-in-action
+ 2
Thank you so much
+ 2
+ there are new advanced features in Java 12 for switch (Sololearn uses java 10)
+ 1
जय भारत, you are welcome 😉