An interface is a collection of abstract methods and constant value definitions, an interface is a special abstract class that contains only the definitions of constants and methods, without the implementation of variables and methods.
interfaces, interfaces: extends, class-A, class: Extends, Class-I interface: Implements
1. Interface can be multiple implementations
2. All variables of the interface are public static final types, which can be not written, default. Abstract of all methods of an interface can be omitted without writing
3. The interface can inherit other interfaces and add new attributes and abstract methods.
4. Multiple unrelated classes can implement the same interface
5. A class can also implement multiple unrelated interfaces
6. There is polymorphism between the interface and the implementation class
Keyword: implements
Public interface Valuable {public double Getmoney ();} Interface protectable {public void beprotected ();} Interface A extends protectable {void m (); void Getmoney ();} Abstract class Animal {private String name;abstract void Enjoy ();} Class Goldenmonkey extends Animal implements valuable, protectable {public double Getmoney () {return 10000;} public void beprotected () {System.out.println ("live in the");} public void Enjoy () {}public void Test () {Valuable v = new Goldenmonkey (); V.getmoney (); protectable p = (protectable) v;p.beprotected ();}} Class Hen implements A, valuable
}
Java Basics-Interface interface