当前位置:网站首页>[method overload]
[method overload]
2022-04-22 07:41:00 【Vi---Rum】
Method overloading
- In the same class The expression of methods with the same name with different method parameter lists is called method overloading
- parameter list Number of parameters Data type of parameter
- The data type of the parameter here Refers to the data type at the same parameter location
- When the method is called , According to the given parameters , To select the method to call , As shown below
public class Demo03 {
public static void main(String[] args) {
// When () The parameters given in are different , The methods selected to call are also different
eat();
eat(" Fruits ");
eat(" Cherry ", 100);
eat(2, " Wonton ");
}
public static void eat() {
System.out.println(" Don't eat anything ");
}
public static void eat(String food) {
System.out.println(" eat " + food);
}
public static void eat(String food, int count) {
System.out.println("foodcount eat " + count + " individual " + food);
}
public static void eat(int count, String food) {
System.out.println("countfood eat " + count + " bowl " + food);
}
}
The output is as follows
Don't eat anything
Eat fruit
foodcount eat 100 A cherry
countfood eat 2 Bowl wonton
版权声明
本文为[Vi---Rum]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220618400770.html
边栏推荐
- Installation and configuration of Yapi (Reprint)
- APC(二)
- A. Weird flecks, but OK (Computational Geometry & three-dimensional minimum circle coverage) (the first game of 2021 Training Alliance warm-up training competition)
- Topic record——
- Leetcode - 6 - (string multiplication, next larger element < Ⅰ Ⅱ Ⅲ >, K sets of inverted linked list)
- D. Determine the photo position (simply find the substring) (2021 Niuke summer multi school training camp 1)
- 2019.1.2 idea usage tutorial
- 换根dp(啊啊啊啊啊)
- FFmpeg命令(六)、 视频提取无音视频
- Page properties
猜你喜欢

爬虫学习之2---requests模块--get请求方式

Detailed overview of this keyword

E. Figure skiing (string sorting / check-in) (Game 5 of 2021 training League warm-up training competition)

Detailed explanation of linked list exercises

Redis的设计与实现(5):主从复制策略和优化

中断门&陷阱门

通过驱动断链来隐藏驱动

Kotlin 协程Flow、StateFlow、ShareFlow

FFmpeg命令(八)、 视频添加水印

Page properties
随机推荐
101012 paging
UNICODE_STRING
The art of concurrent programming (9): the use and principle of final
X64基础(一)
Educational Codeforces Round 125 (Rated for Div. 2)
Ffmpeg command (VII), combining audio and video into video
Links summary qwq
访问修饰符
E. Figure skiing (string sorting / check-in) (Game 5 of 2021 training League warm-up training competition)
FFmpeg命令(六)、 视频提取无音视频
Change DP (ah ah ah)
Leetcode - 2 - (parenthesis generation, longest palindrome string, ring linked list, reverse linked list, nodes in pairwise exchange linked list)
Bidirectional circular linked list (see details)
并发编程的艺术(3):深入理解Synchronized的原理
【调用方法】
深入理解MySQL(7):MySQL如何调优
Page properties
APC(一)
Redis的设计与实现(4):什么是Redis的事件驱动程序
Longest ascending sequence