java error prompts the reason for missing method body or declaring abstraction

Possible cause of the problem:

  1. The method body was not provided when the method was declared

  

public class Test{
  public void show();
{
}

  Explanation: The statement block and content in {} are the main content of the method. If you do not add {}, you should abstract this method as follows:

 

abstract public class Test{
  public abstract void show();
}

  2. The method statement has a semicolon in front of the method body, which makes the method body unrecognizable

 

public class Test{
public void show();
{
    System.out.println("ok");
}
}

  3. The class continues the abstract class and implements the interface without rewriting abstract methods

 

public abstract class Base{
    public void show();
}
public class Test extends Base{
    public void print()
    {
        System.out.println("print");
    }
}

  

Guess you like

Origin www.cnblogs.com/sgy614092725/p/shiguiyu23.html