如果我有方法
void f(byte b);
Run Code Online (Sandbox Code Playgroud)
如何在不进行强制转换的情况下使用数字参数调用它?
f(0);
Run Code Online (Sandbox Code Playgroud)
给出错误.
我有一个代码片段:
class AutoTypeCast{
public static void main(String...args){
int x=10;
byte b=20;//no compilation error
byte c=x;//compilation error
}
}
Run Code Online (Sandbox Code Playgroud)
为什么20会自动键入式浇铸byte,而x不是?