+ 2
Why can't I use * as case'*'? Please answer me.
Please answer me if you know. I really need to know that.
2 Answers
+ 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");
}
}
}
0
Mr.Ipang . I will show you my code . Then you can tell me something .