To overcome the drawbacks of Java single inheritance, Java introduces an interface:
An interface is not a class, it is a description of a set of requirements for a class, consists of constants and a set of abstract methods, all methods in an interface are automatically public, the method is declared in an interface without having to provide the keyword public, and the domain in the interface is automatically set to public static final. The interface must never contain an instance domain, and the task that provides the instance domain and method implementation should be done by the class that implements the interface, so that the interface can be treated as an abstract class without an instance domain. Definitions between interfaces can use an inheritance relationship (public interface interface 1 extends interface 2)
The two steps that must be made to enable a class to implement an interface are: (1) to declare the class to implement the given interface (2) to define all the methods in the interface (declaring the class to implement an interface that requires the use of the keyword implements)
There can be no final in an interface constant, and an abstract method can be without an abstract.
When copying an object variable, the original variable references the same object as the copy variable. If you want to create a new copy of an object, its original state is the same as original, but you can change the state of each one later, you need to use the Clone method of the object class. The Clone () method in the object class is decorated with the protected modifier. This also means that it cannot be called directly in the user-written code. If a class does not implement the Cloneable interface and invokes the Clone () method of object (which also calls the Super.clone () method), then the Clone () of Object Method throws a Clonenotsupportedexception exception
A class can have only one method, but it is possible to implement multiple interfaces, separating each interface with commas
Callback: is a programming pattern that can refer to actions that should be taken when a particular event occurs. Announcements in the Java.swing package there is a timer class that can be used to issue an advertisement at a given time interval
Functional interfaces: For interfaces with only one abstract method, you can provide a lambda expression when an excuse object is required
There are three ways to define a comparer: (1) Traditional method (2) lambda expression (3) Inverse name inner class
JAVA Sixth Chapter Knowledge Review and summary