Why java interface methods are public abstract modification? Why property is public static final modification?

 Why java interface methods are public abstract modification?

  1, we must first understand and define what is the role of the interface:

              Interface definition: the interface is a collection of all the abstract methods composition, which are constants and abstract methods, a modified interface.

              Interface effects: as a specification class "Protocol" specification implementation class, enhanced scalability.

          Know the definition and role of the interface, then it is not difficult to understand why interface methods are pubilc abstract modified, and this is the case, the interface corresponding to the interface implementation class must be implemented in accordance with specifications, details of the interface does not matter, just According to this specification is achieved.

          If the interface methods are abstract methods, abstract method is no method body, the body no matter what method is achieved in that class, just follow the interface specification to write the name of the method can be, do not care about the method body in how to write.

          Like the computer's USB slot, the host computer where you USBU tube plate is what type, how much memory, which brand is which country production, provided that they meet the host of the slot size, opinions can plug in, no matter the details of your U disk.

    

Why property is public static final modification?

  1, this is also related to the definition and role of the interface. As already said, the definition and role of the interface, then

      final: Because this is where the interface, the interface is a specification, you can not change values, with final modifications property, with final modification of the properties, called constants.

      static: 1, because the interface is not creating an object, only use static constants to the interface through the interface name to access. 2, and the java syntax is, if the class implements an interface C A and B interfaces, the interface A, B have the same variable N, then the interface may be distinguished by names.

Guess you like

Origin www.cnblogs.com/eyjdbk/p/10963261.html