【发布时间】:2013-09-06 10:43:43
【问题描述】:
此代码有错误
public class DoIt {
public static void main(String[] args) {
final class Apple {
public static String place = "doIt";
}
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
System.out.println(Constants.place);
}
});
thread.start();
}
}
错误-The field name cannot be declared static in a non-static inner type, unless initialized with a constant expression
【问题讨论】:
-
什么是 Constants.place?您如何在代码中使用 Apple 类?
标签: java static nested-class