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

边栏推荐
- Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
- 雲計算未來 — 雲原生
- 基于Linu开发的项目视频
- 十條職場規則
- elastic_ L01_ summary
- Record your vulnhub breakthrough record
- Recovery of website address and method of Amazon account login two-step verification failure caused by mobile phone number becoming empty
- 111. Minimum depth of binary tree
- 剑指Offer10- I. 斐波那契数列
- 【嵌入式】---- 内存四区介绍
猜你喜欢

Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)

Alibaba is bigger than sending SMS (user microservice - message microservice)

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

Application of ncnn Neural Network Computing Framework in Orange Pi 3 Lts Development Board

Record your vulnhub breakthrough record

Powerful avatar making artifact wechat applet

剑指Offer03. 数组中重复的数字【简单】

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?

Xctf mobile--app2 problem solving

ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍
随机推荐
1-1 token
Sword finger offer09 Implementing queues with two stacks
Applet wxss introduction
The latest version of blind box mall thinkphp+uniapp
Adult adult adult
最新版抽奖盲盒运营版
Using swift language features, write a pseudo-random number generator casually
Application of ncnn Neural Network Computing Framework in Orange Pi 3 Lts Development Board
Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
temp
启用MemCached的SASL认证
Idea packages the web project into a war package and deploys it to the server to run
2021 autumn Information Security Experiment 1 (password and hiding technology)
I'm too lazy to write more than one character
记录自己vulnhub闯关记录
T430 toss and install OS majave 10.14
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements
Do you feel like you've learned something and forgotten it?
01_ Using the concurrent tool class library, is thread safety safe
JVM内存模型