Reputation: 31
interface Workables {
void Work();
}
public class AnonymousTry {
public static void main(String[] args) {
Workables w = new Workables() {
static int x = 10;
public void Work() {
System.out.println("Working..."+x);
}
};
w.Work();
}
}
I can run without any errors in Eclipse, but couldn't in online compilers. I am confused about whether the anonymous inner class allows static variables inside it or not.
Upvotes: 1
Views: 52