+ 2

Why can't I use * as case'*'? Please answer me.

Please answer me if you know. I really need to know that.

5th Sep 2018, 2:00 AM
pyone cho
pyone cho - avatar
2 odpowiedzi
+ 2
You mean case within a switch statement? I think it should work, but it needs be wrapped in double quotes (String) rather than single quotes (char). import java.util.Scanner; public class Asterisk { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); switch(s) { case "a": System.out.print("Lowercase A"); break; case "*": System.out.print("Asterisk"); break; default: System.out.print("Others"); } } }
5th Sep 2018, 2:48 AM
Ipang
0
Mr.Ipang . I will show you my code . Then you can tell me something .
9th Feb 2019, 12:12 PM
pyone cho
pyone cho - avatar