class Test{
static void testCase_1(long l){System.out.println("Long");}
static void testCase_2(Long l){System.out.println("Long");}
public static void main(String args[]){
int a = 30;
testCase_1(a); // Working fine
testCase_2(a); // Compilation time error
//Exception - The method testCase_2(Long) in the type Test is not applicable for the arguments (int)
}
}
测试用例 - 1: int - long 正常工作
测试用例 - 2: 将 int 转换为 Long 抛出异常
为什么 testCase_2() 方法抛出编译异常?