当前位置:网站首页>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......");
}
边栏推荐
- FS4059A与FS5080E充电芯片的区别
- Wechat applet: elderly blessing short video
- Yingjixin launched 4 series of lithium batteries 100W mobile power supply voltage rise and fall scheme SOC chip ip5389
- Design and implementation of spark offline development framework
- 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
- MySQL面试真题(二十三)——拼多多-球赛分析
- About replay attack and defense
- Redis缓存穿透解决方案-布隆过滤器
- Special research on Intelligent upgrading of heavy trucks in China in 2022
- 数据库连接异常:create connection error, url: jdbc:mysql://ip/数据库名, errorCode 0, state 08S01问题处理
猜你喜欢

数字藏品赋能实体产业释放了哪些利好?

Lihongyi, machine learning 5 Tips for neural network design

MySQL面试真题(二十五)——常见的分组比较场景

高等数学(第七版)同济大学 习题1-8 个人解答

Wechat applet: elderly blessing short video

MySQL面试真题(二十一)——金融-贷款逾期

Wechat applet: Star Trek spaceship ticket production and generation

云原生数据库是未来数据库的天下

What does the English letter PC mean? What does the Internet PC mean

Yingjixin ip6806 wireless charging scheme 5W Qi certified peripheral simplified 14 devices
随机推荐
GDB data reading in GDAL (III) of GIS
GO语言-自定义error
The weak are as irritable as tigers, the strong are as calm as water, and the really powerful have already given up their emotions
visdom的使用
Real MySQL interview question (XXVIII) -- case - Analysis of indicators of communication operators
SIFT feature point extraction
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
ArcTime 制作中英文字幕视频
Wechat applet: future wife query generator
STM32 clock tree misconfiguration causes boot to enter hard interrupt
Go language - use of packages
Leetcode 797: all possible paths
jvm: 方法重载时,具体调用哪个方法,是由传入参数的静态类型来决定的,而不是由参数的实际类型来决定
Win software - (net framework) processed the certificate chain but terminated in a root certificate that is not trusted by the trusted provider
MDM数据清洗功能开发说明
手机无线充电双线圈15W方案SOC英集芯IP6809
IP6809三线圈15W无线充电发射端方案ic英集芯
WebRTC[47] - WebRTC 保存 YUV 数据的常用方式
MySQL面试真题(二十一)——金融-贷款逾期
B-string value (string DP) of the 16th Northeast College Students' Programming Competition (warm-up)