In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "the difference between overloading and rewriting in java". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Overloading: for example, a method in a class, such as the add () method, can be expressed in three forms, add (int a), or add (int aline int b), or add (int a line int bline int c), which makes a class polymorphic. Overloading only requires the same method name
Rewrite: the subclass redefines the function of the parent class so that the class name and parameter type are the same, thus realizing the polymorphism of the parent class and the subclass. The shell remains the same, the core is rewritten!
The constructor of the parent class cannot be overridden because the constructor of the parent class should be the same as the class name, and if overridden, the subclass name must be the same as the parent class name. Two classes with the same name are not allowed in Java. Benefit: subclasses can implement the methods of the parent class as needed. Note that methods defined as final and static in the parent class cannot be overridden.
You can think of rewriting as a special case of overloading.
That's all for the content of "the difference between overloading and rewriting in java". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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: 270
*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.