//需求:使用方法重载思想,设计比较两个数是否相同,兼容全整数类型(byte,short,int,long)
public static void main(String[] args) {
System.out.println(compare(10,20));
System.out.println(compare((byte)10,(byte)20));
System.out.println(compare((short)10,(short)20));
System.out.println(compare(10L,20L));
}
//int
public static boolean compare(int a ,int b){
System.out.print("int ");
return a==b;
}
//byte
public static boolean compare(byte a ,byte b){
System.out.print("byte ");
return a==b;
}
//short
public static boolean compare(short a ,short b){
System.out.print("short ");
return a==b;
}
//long
public static boolean compare(long a ,long b){
System.out.print("long ");
return a==b;
}