无论何时我使用字节或短数据类型作为方法参数,在方法调用时,我都需要明确地转换传递给这些方法的值。函数调用所需的类型转换以short数据类型变量作为参数
为了更好地解释:
void foo(short x)
{}
void main() {foo((short)32);}
如果我不使用短这里则生成的警告。
method foo in class px cannot be applied to given types
required: byte
found: int
我怎样才能让它变得更好?
这是一个重复的http://stackoverflow.com/questions/477750/primitive-type-short-casting-in-java – 2011-02-24 15:41:37