1.1 updated overview of the composition of the interface
consisting of interface
● Constant
public static Final
● abstract methods
public abstract
● default method (the Java 8)
● static method (the Java 8)
● private method (Java9)
1.2 Interface default method
Interface method defined default format:
● Format: public default return type method name (parameter list) {}
Example: public default void show3 () {}
The default interface method Notes:
● The default method is not abstract method, it is not mandatory to be rewritten. But can be rewritten, rewritten when removing the default keyword
● public can be omitted, default can not be omitted
public interface MyInterface { void show1(); void show2(); // void show3(); public default void show3() { System.out.println("show3"); } }
1.3 Interface static methods
defined format interface static methods:
● Format: public static return type method name (parameter list) {}
● Example: public static void show () { }
interfaces static methods Note:
● Static The method calls only through the interface name, class name can not be achieved by object name or call
● public may be omitted, static can not be omitted
1.4 interface private methods
Java 9 added a private body with methods, which is actually in Java 8 foreshadowed: The default method is defined with a method body interface in Java 8 permit
and static methods. This might lead to eleven question: When two default methods or static methods contained in the same section of code implementation, the program is bound to consider
the realization of this code is drawn into a common method, but this method does not require the common people used, hence the private to hide, this is the Java 9
increases Necessity private process
definitions format private methods Interface:
format 1: private return type method name (parameter list) {}
● example 1: private void show ( )} {
● Format 2: private static method return type name (parameter list) {}
● Example 2: private static void method ({ }
Notes interface private methods:
● default method can call private static methods and non-static methods
● static method can only be called private static method