重载时,为什么byte和short变量相乘结果强制转化了,int没有呢?
在计算器中定义加、减、乘、除等方法
在方法中对接收的两个数字进行运算
并使用重载的知识根据数字类型选择相应的方法计算。
*/
float counter(float a,float b){
return(a*b);
}
double counter(double a,double b){
return(a*b);
}
int counter(int a,int b){
return(a*b);
}
long counter(long a,long b){
return(a*b);
}
short counter(short a,short b){
return (short) (a*b);
}
byte counter(byte a,byte b){
return (byte) (a*b);
}
public static void main(String[] args){
}
}
为什么byte和short变量相乘结果强制转化了,int没有呢