In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "java polymorphic application case analysis", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "java polymorphic application case analysis"!
The operating environment of this tutorial: windows7 system, java10 version, DELL G3 computer.
1. Concept
Polymorphism is the third major feature of object-oriented after encapsulation and inheritance. Is a parent class reference that points to a subclass object.
2. Format
Parent class type variable name = new subclass type ()
3. Conditions of use
Must have a child-parent relationship.
4. Examples
Public class Wine {public void drinkWine () {System.out.println ("= what am I going to drink today?); Wine ();} public void Wine () {System.out.println (" see what I can drink today. }} public class JNC extends Wine {/ * @ desc subclass overload parent method * this method does not exist in the parent class. After the upward transformation, the parent class is * @ param a * @ return void * / public void drinkWine (String a) {System.out.println ("= today I want to drink Jiannanchun ="); Wine () } / * subclass overrides the parent method * when calling Wine to the parent reference of the subclass, the method must be called * / public void Wine () {System.out.println ("= Jiannanchun drank, good Kessen =");}} public class Test {public static void main (String [] args) {Wine a = new JNC (); a.drinkWine () A.Wine (); Wine b = new Wine (); b.drinkWine (); b.Wine (); JNC c = new JNC (); c.drinkWine ("qq") }} Thank you for your reading. the above is the content of "java Polymorphism Application case Analysis". After the study of this article, I believe you have a deeper understanding of the problem of java Polymorphism Application case Analysis, and the specific usage needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.