好的,大家都相信这是一个简单的解决方法。
public class function {
public static void main(String[] args)
{
public boolean playButton = true;
public boolean playMusic() {
if (playButton) {
System.out.println("Music");
} else {
System.out.println("No Music");
}
}
}
我想要的只是终端打印音乐。
答案 0 :(得分:1)
您应该在'main'方法之外声明'playMusic'函数并从main调用它,尝试这样的事情:
public class function {
static boolean playButton;
public static void main(String[] args)
{
playButton = true;
playMusic();
}
public static void playMusic() {
if (playButton) {
System.out.println("Music");
} else {
System.out.println("No Music");
}
}
}
答案 1 :(得分:0)
public class function {
public static boolean playButton = true;
public static void playMusic() {
if (playButton == true) {
System.out.println("Music");
} else {
System.out.println("No Music");
}
}
public static void main(String[] args)
{
playMusic()
}
}