I am having a few problems with this build. First it is not all it will not load the main class. Second I need the user to input their choice of music and then I need the compiler to print selection. Can someone help me with this code? Please excuse me but I am totally new to programming.
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();
}
public static void music(String[] args)
This does not look like main method. You should use main in place of music: -
public static void main(String[] args)
Also, the compilation unit containing this class should have the same name as that of the class. And better use your class name as : - Music and save it as Music.java
Your method must be named main. Review this tutorial.
Instead of:
public static void music(String[] args) {
try:
public static void main(String[] args) {
public static void music(String[] args) defines a static method with the same names as the class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With