Java Nested Interface
Chapter:
Miscellaneous
Last Updated:
25-03-2017 06:12:00 UTC
Program:
/* ............... START ............... */
// Nested Interface declared within the Interface
public interface OuterInterface
{
//OuterInterface method declarations
interface NestedInterface
{
//NestedInterface method declarations
}
}
//Nested Interface declared within the class
public class OuterClass
{
//OuterClass method and variables
interface NestedInterface
{
//NestedInterface method declarations
}
}
/* ............... END ............... */
Notes:
-
Java programming allows you to declare an Interface within another Interface or Class. Such type of Interfaces are called Nested or Inner Interface.
- The Nested Interface must be referred by the outer Interface or class.
- Nested Interface cannot be accessed directly.
- Nested interface must be public if it is declared inside the interface but it can have any access modifier if declared within the class.
- Nested interfaces are declared static implicitely.
Tags
Nested Interface, Miscellaneous, Java