I've started preparing myself for the OCJP7 exam and I found this chapter that seems to be very complicated.
Let's say I have this code:
class Outer1{
interface InnerInterface{
String x = "test";
}
class InnerClass{
String x = "test";
}
}
class Outer2{
static interface NestedInterface{
String x = "test";
}
static class NestedClass{
String x = "test";
}
}
class Main{
public static void main(String [] args){
String s1 = Outer1.InnerInterface.x;
String s2 = new Outer1().new InnerClass().x;
String s3 = Outer2.NestedInterface.x;
String s4 = new Outer2.NestedClass().x;
}
}
Could you tell me why we can access Outer1.InnerInterface.x
and Outer2.NestedInterface.x
in the same manner? Inner interfaces are static by default? I'm trying to make some connections to make them more clearly.