当前位置:网站首页>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

边栏推荐
- 【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
- Sword finger offer05 Replace spaces
- With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?
- Application of ncnn neural network computing framework in orange school orangepi 3 lts development board
- 2.9 overview of databinding knowledge points
- Kubectl_ Command experience set
- Pytext training times error: typeerror:__ init__ () got an unexpected keyword argument 'serialized_ options'
- [ArcGIS user defined script tool] vector file generates expanded rectangular face elements
- temp
- 阿里 & 蚂蚁自研 IDE
猜你喜欢
![[download attached] password acquisition tool lazagne installation and use](/img/21/eccf87ad9946d4177b600d96e17322.png)
[download attached] password acquisition tool lazagne installation and use

如何在微信小程序中获取用户位置?

Sword finger offer05 Replace spaces

4. 无线体内纳米网:电磁传播模型和传感器部署要点

云计算未来 — 云原生

剑指Offer10- I. 斐波那契数列

If you can't learn, you have to learn. Jetpack compose writes an im app (II)

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

ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍
随机推荐
如何在微信小程序中获取用户位置?
1-1 token
Low code platform international multilingual (I18N) technical solution
写一个简单的nodejs脚本
elastic_ L04_ introduction. md
Swift bit operation exercise
【ManageEngine】IP地址扫描的作用
If you can't learn, you have to learn. Jetpack compose writes an im app (I)
Swift5.7 扩展 some 到泛型参数
Swift return type is a function of function
Alibaba is bigger than sending SMS (user microservice - message microservice)
The future of cloud computing cloud native
Exploration of sqoop1.4.4 native incremental import feature
启用MemCached的SASL认证
The best shortcut is no shortcut
基于同步坐标变换的谐波电流检测
2020-11_ Technical experience set
2.8 overview of ViewModel knowledge
Official website of Unicode query
What is more elegant for flutter to log out and confirm again?