Cannot run code with a method
Posted: Fri Jan 05, 2018 9:08 pm
I know below code is accurate since it's straight out of a course.
Just get:
"Error: Main method not found in class Robot, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application"
The main method is obviously in the main method...
So why doesn't it work?
//java
/*Method parameters 1
** Robot
*/
class Robot {
public void speak(String text) {
System.out.println(text);
}
}
public class Method1 {
public static void main(String[] args) {
Robot sam = new Robot();
sam.speak("Hi I'm Sam");
}
}
Just get:
"Error: Main method not found in class Robot, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application"
The main method is obviously in the main method...
So why doesn't it work?
//java
/*Method parameters 1
** Robot
*/
class Robot {
public void speak(String text) {
System.out.println(text);
}
}
public class Method1 {
public static void main(String[] args) {
Robot sam = new Robot();
sam.speak("Hi I'm Sam");
}
}