Reputation: 33
This may be silly to ask, but looking at following code raises a question.
public class Outer {
public class Inner {
public static final int variable = 100;
}
public static void main(String[] args) {
int test = Outer.Inner.variable; // Inner Non-Static accessed
// with Class reference?
}
}
How can the non-static nested class be accessed with a class reference?
Upvotes: 1
Views: 77
Reputation: 41168
The variable is static, and that is what matters. Since the variable is static you can always access it with the class reference.
Upvotes: 3