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

边栏推荐
- 十条职场规则
- If you can't learn, you have to learn. Jetpack compose writes an im app (II)
- Solve the problem of VI opening files with ^m at the end
- [ManageEngine] the role of IP address scanning
- ORM use of node -serialize
- Applet wxss introduction
- Is it safe to open an account for online stock speculation? Who can answer
- alright alright alright
- 双链笔记·思源笔记综合评测:优点、缺点、评价
- 01_ Using the concurrent tool class library, is thread safety safe
猜你喜欢

Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?

Application of ncnn neural network computing framework in orange school orangepi 3 lts development board

Record your vulnhub breakthrough record

TOGAF认证自学宝典V2.0

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

Analysis of a music player Login Protocol

(latest version) WiFi distribution multi format + installation framework

initial、inherit、unset、revert和all的区别
![[download attached] password acquisition tool lazagne installation and use](/img/21/eccf87ad9946d4177b600d96e17322.png)
[download attached] password acquisition tool lazagne installation and use

Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
随机推荐
I'm too lazy to write more than one character
Approve iPad, which wants to use your icloud account
GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
最新版抽奖盲盒运营版
What is more elegant for flutter to log out and confirm again?
CNN MNIST handwriting recognition
The difference between lambda and anonymous inner class
1-2 project technology selection and structure
Airflow installation jump pit
How to convert a decimal number to binary in swift
init. RC service failed to start
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements
Kubectl_ Command experience set
Differences between initial, inherit, unset, revert and all
剑指Offer04. 二维数组中的查找【中等】
手机号码变成空号导致亚马逊账号登陆两步验证失败的恢复网址及方法
阿里 & 蚂蚁自研 IDE
Self made pop-up input box, input text, and click to complete the event.
2.8 overview of ViewModel knowledge
云计算未来 — 云原生