设为首页
收藏本站
切换到宽版
登录
立即注册
找回密码
搜索
搜索
本版
帖子
用户
快捷导航
论坛
BBS
VIP用户组
官网群
无名商城论坛
»
论坛
›
资源分享区
›
学习资源专区
›
【分享】【记录】寒假学Java(14—2)
返回列表
发帖
查看:
277
|
回复:
0
[其他技术]
【分享】【记录】寒假学Java(14—2)
[复制链接]
无名
无名
当前离线
积分
32464
1万
主题
1万
帖子
3万
积分
管理员
积分
32464
发消息
发表于 2022-5-8 18:25:37
|
显示全部楼层
|
阅读模式
//重载小练习//判断两个数是否相等
//byte short int long
参数列表不同
代码
public class TestfunctionOverload {
public static void main(String[] args) {
System.out.println(isSame((byte) 10,(byte) 20));
//强制类型转换
System.out.println(isSame((short)10,(short)20));
System.out.println(isSame(10,20));
System.out.println(isSame((long) 10,(long) 20));
}
public static boolean isSame(byte a,byte b){
return a==b;
}
public static boolean isSame(short a,short b){//参数列表不同
return a==b;
}
public static boolean isSame(int a,int b){
return a==b;
}
public static boolean isSame(long a,long b){
return a==b;
}
}
isSame
,
public
,
static
,
short
,
println
相关帖子
•
【HC】JAVA中全局变量
•
【HC】一个简单的java程序
•
【HC】简单理解实咧
•
【HC】转型对象(Java)
•
【HC】【考核】设计模式——解释器模式
•
java輸出hello world練習
•
【Box】Java零基础1,小白教程,大佬勿喷
•
【FUT】Java代码分享-打印九九乘法表
回复
使用道具
举报
返回列表
发帖
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
本版积分规则
发表回复
回帖后跳转到最后一页
快速回复
返回顶部
返回列表