Nested Interfaces

Like a class you have seen, an interface can be nested within a) a class or b) another interface. That is, an interface can be declared inside a class body or interface body.

That is, an interface can declare within it, classes, interfaces, instance variables and abstract methods. Let us see one by one.

1. An interface declared wihtin a class can be of any access specifier and need not be static.

2. An interface declared within another interface must be public only and is implicitly static. That is, inner interface should be public.

Three variations are given in this category of Nested Interfaces.

1. Interface inside Interface
2. Nested Interface within Class
3. Class inside Interface

Leave a Comment

Your email address will not be published.