+ 2

My complier seems to find error in this code, what might be the problem?

//This is a switch expression &! statement. String dayType = switch(day) { case 1, 2, 3, 4, 5 -> "working day"; case 6,7 ->"weekend"; default->"No match"; };

15th Feb 2022, 5:37 AM
Dennis
Dennis - avatar
4 Respuestas
+ 1
Thanks Manav Roy
15th Feb 2022, 8:11 PM
Dennis
Dennis - avatar
+ 4
Maybe you missed to declare variable day.
15th Feb 2022, 5:40 AM
Simba
Simba - avatar
+ 3
Before declaring dayType string
15th Feb 2022, 5:51 AM
Simba
Simba - avatar
+ 2
Where should I declare the variable day Simba?
15th Feb 2022, 5:46 AM
Dennis
Dennis - avatar