public static void test(int x, int y) { Thread thread = new Thread() { @Override public void run() { System.out.println(x); } }; thread.start();}這是我的代碼。我無法獲得x的價值。函數匿名類的方法中如何獲取參數x的值?
1 回答

慕后森
TA貢獻1802條經驗 獲得超5個贊
聲明參數xfinal
public static void test(final int x, int y) {
Thread thread = new Thread() {
@Override
public void run() {
System.out.println(x);
}
};
thread.start();
}
添加回答
舉報
0/150
提交
取消