Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the java dynamic binding method

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to use java dynamic binding method", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "java dynamic binding method how to use" article.

Usage

1. The program actually calls the eat method of the parent class when compiling, but it runs the eat method of the subclass at run time, and binding occurs during the run.

2. Using the previous question, transform upward first, and call the override method with the same name of the parent class and the child class through the parent class reference.

Example

Package chapeter04; class Test {public Test () {} public void setName (String n) {this.name=n;System.out.println ("in parent");} public String getName () {return this.name;} private String name;} public class Sample4_12 extends Test {public void setArea (String a) {this.area=a;} public String getArea () {return this.area;} public static void main (String [] args) {/ / TODO Auto-generated method stubSample4_12 child = new Sample4_12 (); Test test [] = new Test [2] Test [0] = child;test [0] .setName ("silence"); test [1] = new Test ();} private String area;} the above is about "how to use java dynamic binding method". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report