In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
First, the concept of inheritance
Inheritance is a cornerstone of java object-oriented programming technology because it allows the creation of hierarchical classes.
Inheritance means that the subclass inherits the characteristics and behavior of the parent class. OA credit disk port erection bbs.yasewl.com (Quan 917899899) makes the subclass object (instance) have the instance field of the parent class, or the subclass inherits methods from the parent class, making the subclass have the same behavior of the parent class. The parent class is more generic and the child class is more specific.
Java is quite different from other object-oriented languages in the means of implementing inheritance. In Java, all inheritance is public inheritance.
Superclasses and subclasses are the two most commonly used terms for Java programmers. Other terms are base class, ancestor class, parent class; derived class, (child) subclass.
Between a subclass and a parent class, "is-a" is an obvious feature of inheritance and a simple rule used to determine whether it should be designed as an inheritance relationship, indicating that each object of the subclass is also an object of the superclass. Another representation of the "is-a" rule is the permutation rule, which indicates that wherever there is a superclass object in the program, it can be replaced with a subclass object.
The prefixes "Super" and "Zi" are derived from the terms of collective language in computer science and mathematical theory.
For example, the employee set is a superset of the manager set, or the manager set is a subset of the employee set.
The difference between this and super:
This and super are both keywords of Java and have special semantics.
1 、 this
1) this is the keyword of Java and has special semantics.
2) this is an implicit reference parameter that the compiler automatically adds to the instance method, and it is a reference parameter to the instance object of this class or its derived class.
3) the parameter cannot have the same name as this.
4) Local variables cannot have the same name as this.
5) the type of this is the type of this class.
6) the value of this is determined when the instance method is called.
7) the value of this is read-only and cannot be changed; however, this can be assigned to another object variable.
8) use of this: this.field, this.method (), this ()
Important: in this class constructor, use this (..) The statement that calls other constructors of this class must be the first statement of the constructor of this class.
2. Super accesses the members of the parent class through the super keyword
1) super is the keyword of Java and has special semantics.
2) super is just a unique keyword that instructs the compiler to call a superclass member. Because super is not a real reference to one object, you cannot assign super to another object variable.
3) the parameter cannot have the same name as super.
4) Local variables cannot have the same name as super.
5) it can be understood that the type of super is the parent type of the class.
6) the value of super can be understood as super = (superclass) this.
7) it can be understood that the value of super is read-only and cannot be changed
8) the use of super: super.field, super.method (), super ().
Important tips:
1. Super.method () tells the Java compiler that the superclass methods called by super are statically bound and there is no polymorphism.
2. In the subclass constructor, use super (..) The statement that calls the superclass constructor must be the first statement of the subclass constructor.
3. If the constructor of the subclass does not explicitly call the constructor of the superclass super (..),
The constructor of this class, this (..), will automatically invoke the superclass's default constructor (constructor super () with no parameters), and if the superclass does not have a default constructor, the Java compiler will report a syntax error.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.