public class Test {
static void test(Integer x) {
System.out.println("Integer");
}
static void test(long x) {
System.out.println("long");
}
static void test(Byte x) {
System.out.println("byte");
}
static void test(Short x) {
System.out.println("short");
}
public static void main(String[] args) {
int i = 5;
test(i);
}
}
輸出值是「long」。int類型值爲什麼不是整數
只能告訴我爲什麼它不是「Integer」,因爲在Java中,int值應該是自動裝箱的。