我在这个版本上遇到了一些问题。首先,它并不是所有的,它不会加载主类。其次,我需要用户输入他们选择的音乐,然后我需要编译器打印选择。有人能帮我写这段代码吗?请原谅,我对编程完全陌生。
public class music {
public static void music(String[] args) {
System.out.println("What's your favorite kind music?: ");
System.out.println("1. Country");
System.out.println("2. Rock");
System.out.println("3. Heavy Metal");
System.out.println("4. Folk");
try{
BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
int s = Integer.parseInt(bufferRead.readLine());
switch(s){
case 1:
System.out.println("Country");
break;
case 2:
System.out.println("Rock");
break;
case 3:
System.out.println("Heavy Metal");
break;
case 4:
System.out.println("Folk");
break;
default:
System.out.println("Country");
break;
}
}catch(IOException e){
e.printStackTrace();
}发布于 2012-10-14 04:01:29
函数名称必须是音乐,而不是main() ()
public class music {
public static void main(String[] args) {
System.out.println("What's your favorite kind music?: ");
System.out.println("1. Country");
System.out.println("2. Rock");
System.out.println("3. Heavy Metal");
System.out.println("4. Folk");
try{
BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
int s = Integer.parseInt(bufferRead.readLine());
switch(s){
case 1:
System.out.println("Country");
break;
case 2:
System.out.println("Rock");
break;
case 3:
System.out.println("Heavy Metal");
break;
case 4:
System.out.println("Folk");
break;
default:
System.out.println("Country");
break;
}
}catch(IOException e){
e.printStackTrace();
}
}
}https://stackoverflow.com/questions/12876471
复制相似问题