In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
The main content of this article is to explain the difference between the usage of java basic knowledge super and this. Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the difference between the usage of java basic knowledge super and this.
There are three uses of the super keyword:
1. In the member method of the subclass, access the member variable of the parent class
2. In the member method of the subclass, access the member method of the parent class
3. In the constructor of the subclass, access the constructor of the parent class
The difference between this and super
The super keyword is used to access the parent content, and the this keyword is used to access the content of this class.
1. In the member methods of this class, access the member variables of this class
2. In the member method of this class, access another member method of this class
3. In the constructor of this class, access another constructor of this class
Note in the third usage:
A, this (...) The call must also be the first statement of the constructor, the only one
B, super and this construction calls cannot be used at the same time.
This method is called by default if public class Zi extends Fu {int num = 20; public Zi () {/ / super (); / / does not write. This (111n); / / No parameter construction of this class. Call the parameter construction of this class} public Zi (int n) {this (1p2);} public Zi (int n, int m) {} public void methodZi () {System.out.println (super.num); / / num} public void method () {super.method () in the parent class; / / method System.out.println of the parent class ("subclass method");} public void showNum () {int num = 10 System.out.println (this.num); / / 20}}
At this point, I believe you have a deeper understanding of "the difference between the usage of java basic knowledge super and this". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.