I finished the seventh day of big data today. Summarize the contents of the abstract class, interface, inner class.
The use of the interface can reduce the coupling of the code, abstract class, embodies the object-oriented characteristics of Java programming. Only single inheritance is supported in Java, that is, each class can inherit only one ancestor parent class, but it can be passed. Interfaces can be implemented more than one, which also implements multiple inheritance of classes from another perspective.
The implementation interface uses the keyword implements, and the abstract class uses the abstract keyword. The methods in the interface are all abstract methods, and abstract classes can have abstract methods or no abstract methods. Abstract classes cannot be instantiated. Subclasses inherit abstract classes and need to implement the abstract methods in the parent class. interface, all of the methods are decorated with public (not write is also public), because the interface is to provide the template for the outside world, need to be implemented by other classes, if the interface method is decorated as private or protected, the other class implements the interface, the method is not accessible, Lost the meaning of implementing the interface. When an interface is to be implemented, the methods defined in the interface must be defined as public, otherwise, they will only get the default package access, so that in the process of inheriting the method, the access permissions are reduced, which is not allowed by the Java visit compiler. In other words, the access rights of the methods in the interface can only be enlarged, not reduced, can be carried forward, not pocketed. The fields defined in the interface are hidden, decorated as static and final.
You can place the definition of one class inside the definition of another class, which is the inner class.
If you want to create an object of an inner class from anywhere other than the non-static method of the outer class, you must specifically indicate the type of the object, as in the main () method: Outerclassname.innerclassname. An inner class object can access all members of its outer class object.
51CTO Big Data Learning 003-abstract classes, interfaces, inner classes