import java.io.*;
public class Color {
public void main() throws IOException {
BufferedReader br;
br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your choice");
System.out.println("Enter V for Violet");
System.out.println("Enter I for Indigo");
System.out.println("Enter B for Blue");
System.out.println("Enter G for Green");
System.out.println("Enter Y for Yellow");
System.out.println("Enter O for Orange");
System.out.println("Enter R for Red");
char choice;
choice = (char) br.read();
switch (choice) {
case V:
System.out.println("The spectrum color is Violet");
break;
case I:
System.out.println("The spectrum color is Indigo");
break;
case B:
System.out.println("The spectrum color is Blue");
break;
case G:
System.out.println("The spectrum color is Green");
break;
case Y:
System.out.println("The spectrum color is Yellow");
break;
case O:
System.out.println("The spectrum color is Orange");
break;
case R:
System.out.println("The spectrum color is Red");
break;
default:
System.out.println("Wrong Input");
}
}
}
它说----> cannot find symbol - variable v
...当我尝试在bluej中编码时。我目前正在学习Java编程,这是我的第一个基本Java程序。
您应该尝试将字母变成实际的字符:
case 'V':
System.out.println("The spectrum color is Violet");
break;
您现在正在执行的操作是检查选择是否为变量V
,该变量当然不存在。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句