当前位置:网站首页>The upward and downward transformation of polymorphism
The upward and downward transformation of polymorphism
2022-07-03 12:44:00 【Persia_ Pepper】
The program has been written with Animal Class and Pig class , among Animal Class only shout Method
Save the information as follows
Memory analysis
If you have to access the rest of the methods 、 attribute
public class Demo {
// This is a main Method , It's the entrance to the program :
public static void main(String[] args) {
Pig p = new Pig();
Animal an = p;// The transformation of : Upward transformation
an.shout();
// Add transformation code :
// take Animal To Pig type :
Pig pig = (Pig)an ;// The transformation of : Move down
pig.eat();
pig.age = 10;
pig.weight = 60.8;
}
}
Corresponding to the memory
Before thinking equals Method
边栏推荐
- Kubectl_ Command experience set
- 公纵号发送提示信息(用户微服务--消息微服务)
- Sword finger offer07 Rebuild binary tree
- wpa_ cli
- Adult adult adult
- temp
- Apache Mina开发手册
- Ten workplace rules
- (latest version) WiFi distribution multi format + installation framework
- Idea packages the web project into a war package and deploys it to the server to run
猜你喜欢
Wechat applet pages always report errors when sending values to the background. It turned out to be this pit!
自抗扰控制器七-二阶 LADRC-PLL 结构设计
Application of ncnn Neural Network Computing Framework in Orange Pi 3 Lts Development Board
最新版盲盒商城thinkphp+uniapp
Self made pop-up input box, input text, and click to complete the event.
Swift bit operation exercise
Powerful avatar making artifact wechat applet
Eureka self protection
阿里大于发送短信(用户微服务--消息微服务)
If you can't learn, you have to learn. Jetpack compose writes an im app (I)
随机推荐
The latest version of blind box mall thinkphp+uniapp
ImportError: No module named examples. tutorials. mnist
Eureka self protection
Enable SASL authentication for memcached
GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
CNN MNIST handwriting recognition
2020-09_ Shell Programming Notes
error: expected reference but got (raw string)
雲計算未來 — 雲原生
flinksql是可以直接客户端建表读mysql或是kafka数据,但是怎么让它自动流转计算起来呢?
elastic_ L04_ introduction. md
手机号码变成空号导致亚马逊账号登陆两步验证失败的恢复网址及方法
2.9 overview of databinding knowledge points
Implement verification code verification
Sword finger offer10- I. Fibonacci sequence
Ten workplace rules
node的ORM使用-Sequelize
Using swift language features, write a pseudo-random number generator casually
阿里 & 蚂蚁自研 IDE
如何在微信小程序中获取用户位置?