Friday, 6 September 2013

Field can't be static?

Field can't be static?

There is error with this code
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();
}
}
Error- The field name cannot be declared static in a non-static inner
type, unless initialized with a constant expression

No comments:

Post a Comment