JAVA basis - to understand interface

Interface
is a more abstract than the abstract class category, which we call the interface
Interface can only write in the abstract method
statement interface
access modifier interface {interface name
can only write an abstract method
}

After JAVA1.8, abstract can be omitted, but he is still an abstract method
constructor interface does not exist
in the interface variables public stratic final
interfaces how to use (implements) to implement the interface

public class implements the interface class name {name

}
If a class implements an interface, this interface we have to rewrite all the abstract methods in
our class can implement multiple interfaces, all interfaces implemented in all the abstract methods have to be rewritten
interface multiple inheritance, with a comma apart (the only interface is the presence of multiple inheritance)
interfaces which was written by one of the function
if the same two abstract method method name your two interfaces, inheritance rewrite after rewrite needs only once

The role of interface:
increase the scalability of the code
to reduce the degree of coupling code (what we call the close coupling degree)

 

Guess you like

Origin www.cnblogs.com/ldmboke/p/11715320.html