package cn.yyhl.day03;
/*
题目要求:
比较两个数据是否相等
参数类型分别是两个byte类型,两个short类型,两个Int类型,两个long类型。
并在main方法中测试。
*/
public class MethodOverloadSame {
public static void main(String[] args) {
System.out.println(same((byte) 'a',(byte) 'b'));
System.out.println(same((short) 20,(short) 20));
int a = 10;
int b = 20;
System.out.println(same(a,b));
System.out.println(same(30L, 30L));
}
public static boolean same(byte a, byte b){
System.out.println("两个byte参数的方法执行");
return a == b;
}
public static boolean same(short a, short b){
System.out.println("两个short参数的方法执行");
return a == b;
}
public static boolean same(int x, int y){
System.out.println("两个int参数的方法执行");
return x == y;
}
public static boolean same(long y, long x){
System.out.println("两个long参数的方法执行");
return y == x;
}
}