当前位置:网站首页>Jvm: when a method is overloaded, the specific method to call is determined by the static type of the incoming parameter rather than the actual type of the parameter
Jvm: when a method is overloaded, the specific method to call is determined by the static type of the incoming parameter rather than the actual type of the parameter
2022-06-23 05:42:00 【amadeus_ liu2】
One 、 Example
package com.example.controller;
public class TestOverload {
public static void main(String[] args) {
Grandpa grandpa=new Grandpa();
Grandpa father=new Father();
Grandpa offspring=new Offspring();
print(grandpa);
print(father);
print(offspring);
}
public static void print(Grandpa grandpa){
System.out.println("print grandpa......");
}
public static void print(Father father){
System.out.println("print father......");
}
public static void print(Offspring offspring){
System.out.println("print offspring......");
}
}
class Grandpa{
}
class Father extends Grandpa {
}
class Offspring extends Father{
}
Two 、 Operation output :
3、 ... and 、 analysis :
grandpa、father、offspring this 3 Object's Static type All are Grandpa, Their Actual type Namely Grandpa、Father、Offspring,
Will this 3 Objects passed to print When the method is used , Because their static type is Grandpa, So they call
public static void print(Grandpa grandpa){
System.out.println("print grandpa......");
}
边栏推荐
- 知识点滴 - 折叠锻打和大马士革钢
- SIFT feature point extraction
- 技能自检 | 想当测试Leader,这6项技能你会吗?
- 云原生大趋势下的容器化技术现状与发展
- 数字藏品市场才刚刚开始
- Is there a real part-time job online? How do college students find part-time jobs in summer?
- hash---------history
- Wechat applet: wechat can also send flash photos to create wechat applet source code download and customize flash time
- What if win11 cannot record audio? Solution of win11 unable to input sound
- Mathematical analysis_ Notes_ Chapter 1: set and mapping
猜你喜欢

Today's sleep quality record 80 points

Three implementation methods: left fixed and right adaptive (Flex, float + BFC, float margin left)

MySQL面试真题(二十四)——行列互换

C prime plus notes d'apprentissage - 2, constantes et formatage io (I / o)

Management system of borrowed books based on SSM framework

Wechat applet: Puzzle toolbox

June 22, 2022: golang multiple choice question, what does the following golang code output? A:3; B:1; C:4; D: Compilation failed. package main import ( “fmt“ ) func mai

Wechat applet: production and generation of love guarantee

抽奖 ddd 代码

高等数学(第七版)同济大学 习题1-8 个人解答
随机推荐
Current situation and development of containerization technology under the cloud native trend
View of MySQL introductory learning (III)
数学分析_笔记_第1章:集合与映射
Build a gocd environment
After the idea code is developed, the code is submitted. If the branch is found to be incorrect after submission, how can I withdraw it
STC 32 Bit 8051 Single Chip Computer Development Example Tutorial one development environment
Lihongyi, machine learning 5 Tips for neural network design
IP6809三线圈15W无线充电发射端方案ic英集芯
MySQL面试真题(二十八)——案例-通讯运营商指标分析
Qimen dunjia assistant decision software
知识点滴 - 折叠锻打和大马士革钢
About replay attack and defense
FS2119A同步升压IC输出3.3V和FS2119B同步升压IC输出5V
visdom画多条动态损失曲线
Software project management 8.4 Software project quality plan
数据库连接异常:create connection error, url: jdbc:mysql://ip/数据库名, errorCode 0, state 08S01问题处理
C primer plus學習筆記 —— 2、常量與格式化IO(輸入/輸出)
Lottery DDD code
Leetcode 797: all possible paths
App automated test appium advanced