The interface to the vernacular Detailed

interface A {} which is defined manner. Only global constants in interfaces and abstract methods

********************************************

Interface will certainly learn to learn downcast and upcast

Upcast: Transformation subclass object down through the parent class object instantiated: The subclasses of the parent class object instance of the object, belonging to the cast

Why have upward transition is present, the phrase explained transparent: This does not reflect the abstract object-oriented programming ideas die, reducing scalability code .. For example: When you define a number of classes such as ABC, etc., and B, C is A subclass in a compilation unit, which is if you want to call a method in the main function, the parameters of this method is the BC object. Now if there is no concept of upward transition, the two main methods in the same time to define the parameters for the different B, C type, but if the concept of utilizing the upward transition, the main only need to define a type of A method parameters can, when invoked, only new B, C on the line. This increases the scalability of the code.

*******************************************************

Next is the interface

Functions as an interface: one is a specification to the worker, and another is to use upward transition. There is a saying in Thinking in Java in: You can use any object you want to call my method, as long as you follow my object interfaces.

Guess you like

Origin www.cnblogs.com/greatPrograme/p/12460741.html