Java two - Interface

Interface: a collection of constants and abstract methods set

Statement way:

public interface shape
{
    public static final PI=3.14;
    public abstract double area();
    public abstract double volume();
}
  • Interface must use the interface keyword to declare
  • Interface can be declared only constants and abstract methods
  • Constant public static final statement [statement] is the default mode, can be omitted
  • Method declaration] [public abstic same way as the default statement can be omitted

Interface Method:

  • Interface methods are abstract method public authority, i.e., modified with abstract;
  • The method gives only the method name, return values, the parameter table can not write the method body;

access permission:

  • There are public access interface and default, but access to the interface only public

Interfaces and classes:

 

Guess you like

Origin www.cnblogs.com/zhulmz/p/11480090.html