java interface summary

1. The default qualifier in the interface: (transferred from Blog Park: java_pro)

a. In Java's interface, the default modifier of member variables is: public static final

, so when we define member variables in the interface, we can

1: public static final String name = "bokeyuan";

2: String name = "bokeyuan" ;

Both of the above can be used, and the old driver is generally the second. Since it is a static final variable, it means that the value of this member variable cannot be modified when it is accessed outside. Therefore, the member variables defined in the interface are generally constants. will not be modified. If you want to modify it, define it in the concrete implementation class of the interface.

 

b. The default modifier of the method is: public abstract

, that is: public abstract, which is used to implement the method by the class that implements the interface. Therefore, when defining methods in the interface, there are also two ways

: 1: public abstract List<String> getUserNames(Long companyId);

2: List<String> getUserNames(Long companyId); the

same old driver is the second.

 

c.interface has two qualifiers: package permissions or public

 

2. A class or interface can implement multiple interfaces.

   An interface can inherit several interfaces, because the interface only involves a certain contract and does not require implementation, so there will be no conflict

3.java1.8 has some new features

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325280370&siteId=291194637