0

The input in switch statement can only be integer or others are also possible?

I tried to use character value and string value as input but getting error in execution

26th Oct 2020, 4:38 PM
Sunil
2 Antworten
+ 3
It is possible to use characters. Can you show your code please?
26th Oct 2020, 4:45 PM
Raj Chhatrala
Raj Chhatrala - avatar
0
public class Program { public static void main(String[] args) { char day = 'a'; switch(day) { case a: System.out.println("Monday"); break; case b: System.out.println("Tuesday"); break; case c: System.out.println("Wednesday"); break; } } } This is my program but showing error
28th Oct 2020, 3:46 AM
Sunil