Interface content Summary

In Java 9+ versions, interfaces, may include:

1. The member variable is actually a constant, the format:
[public] [static] [Final] Data type constant name = data value;
Note:
constants must be assigned, and can not be changed once the assignment.
Constant names entirely in uppercase, separated by underscores.

2. The most important interface is an abstract method, in the format:
[public] [abstract] method return type name (parameter list);
Note: implement the interface must cover all the abstract methods override class, unless implement class is abstract.

3. 8 starting from Java, the interface defined in the default method allows the format:
[public] default method return type name (parameter list) {} method body
Note: The default method may be overwritten

4. Starting with Java 8, the interface allows to define a static method in the format:
[public] static method return type name (parameter list) {} method body
Note: It should be called by the name of the interface, can not be achieved by a static class object call interface method

5. Starting Java 9, allows the definition of proprietary interfaces are lack in the format:
Normal Private Method: private method return type name (parameter list) {} method body
static private method: private static method return type name (parameter list) {method body}
Note: private method can be called only by the interface itself, it can not be a class or used by others.

Guess you like

Origin www.cnblogs.com/King-boy/p/11233799.html