Java Error Messages Tutor
Missing Method Body


Error:

    missing method body, or declare abstract
    <method header>;

Explanation:

The compiler found a semicolon after a method header. A semicolon should be used only when the method is abstract.

Checklist:

  • Is there a semicolon after the method header shown in the error message? Semicolons should only be put after methods that are abstract. Abstract methods have the keyword abstract in the method header.

Example:

With the following statements in a source file named Input.java:

1 /* Input class */
2
3 public class Input
4 {
5   public static void main( String [] args ); // note semicolon
6   {
      // more code here

the Java compiler would generate the following error:

Input.java:5: missing method body, or declare abstract
public static void main( String [] args );
                   ^

To fix the problem, remove the semicolon after the main method header.

Back to main page