Reputation: 1338
I cannot understand why this even compile. I've tried with different formats and they all seem to work..
why is it legal to have an enum of enum of enum of..
?
interface I {
enum E implements I {
VAL;
}
class Test {
I.E f1 = I.E.VAL;
I.E.E f2 = I.E.VAL;
I.E.E.E f3 = I.E.VAL;
I.E.E.E.E.E f4 = I.E.VAL;
I.E v1 = I.E.VAL;
I.E v2 = I.E.E.VAL;
I.E v3 = I.E.E.E.E.E.E.VAL;
I.E v4 = I.E.E.E.E.E.E.E.E.E.E.VAL;
}
}
My IDE reports it compiles just fine, although I.E.E
does not make sense to me.
Upvotes: 13
Views: 569
Reputation: 887767
Your I
interface contains an enum type named E
.
This type implements that same I
interface, so it inherits everything that that interface contains.
This includes the E
type itself.
In other words, I.E.E
is accessing I.E
as inherited by E
from the outer I
.
Upvotes: 11