I have trawled through the internet for a solution to this and I still don't understand why I am getting the following error message:
"Error: Main method not found in class DrumKit, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application"
Here is my code:
DrumKit.java
class DrumKit {
boolean topHat = true;
boolean snare = true;
void playTopHat() {
System.out.println("ding ding da-ding");
}
void playSnare() {
System.out.println("bang bang ba-bang");
}
}
DrumKitTestDrive.java
class DrumKitTestDrive {
public static void main(String [] args) {
DrumKit d = new DrumKit();
d.playSnare();
d.snare = false;
d.playTopHat();
if (d.snare == true) {
d.playSnare();
}
}
}
I am using InteliJ and I input the command javac DrumKitTestDrive.java
followed by java DrumKit.
This is from an exercise from the Head First Java series and my answer is exactly the same as the one from the book. But I still encounter this error.