+ 2
What is wrong with this code?
boolean button =true; public void playMusic(){ if (button){ System.out.println("play music"); }else{ System.out.println("music paused"); } }
4 Answers
+ 14
public class Program
{
public static void main(String[] args){
boolean button =true;
playMusic(button);
}
static void playMusic(boolean button){
if (button){
System.out.println("play music");
}else{
System.out.println("music paused");
}
}
}
//corrected program , it will work âș
//mark john wells sir answer as best , sir is right
+ 5
If you are calling it from main and declaring it within the Program class, it needs to be static.
+ 3
nothing. what error are you getting?
+ 3
if you make it static, you will need to also make your variable static