無論何時我使用字節或短數據類型作爲方法參數,在方法調用時,我都需要明確地轉換傳遞給這些方法的值。函數調用所需的類型轉換以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