我想打印这个标志/\
,但在编译器上,我认为一切都很好,但无法编译。错误显示为
leets.java:13: error: unclosed string literal
System.out.printf ("%s /\",ch);
^
leets.java:13: error: ';' expected
System.out.printf ("%s /\",ch);
^
2 errors
我的代码如下。
import java.util.Scanner;
public class switchDemo2
{
public static void main ( String args[] )
{
Scanner i = new Scanner ( System.in );
System.out.print ( "Enter a character to test: " );
char ch;
ch = i.next().charAt(0);
switch ( ch )
{
case 'A': case 'a':
System.out.printf ("%s /\",ch);
break;
case 'B': case 'b':
System.out.printf ("%s 13",ch);
break;
case 'C': case 'c':
System.out.printf ("%s )",ch);
break;
case 'D': case 'd':
System.out.printf ("%s 1)",ch);
break;
case 'E': case 'e':
System.out.printf ("%s 3",ch);
break;
case 'F': case 'f':
System.out.printf ("%s 1=",ch);
break;
default:
System.out.printf ("%s not a lowercase vowel\n",ch);
}
}