[英]How to get the value of the x variable?
public static void test(int x, int y) {
Thread thread = new Thread() {
@Override
public void run() {
System.out.println(x);
}
};
thread.start();
}
This is my code. 这是我的代码。 I can't get value of x .
我无法获得x的值。 How do I get the value of the parameter x in the method of the anonymous class of the function?
如何在函数的匿名类的方法中获取参数x的值?
Declare parameter x
final 声明参数
x
最终值
public static void test(final int x, int y) {
Thread thread = new Thread() {
@Override
public void run() {
System.out.println(x);
}
};
thread.start();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.