FAQ

Java

JSP

Servlet


Advertisement



How to access inner class in an interface?

An inner class always behaves like a data variable of its encoding class or interface. By default all variables which are declared in an interface are final and static. A class defined inside an interface is implicitly static.

interface InterfaceXYZ {
class InnerXYZ {
}
}
class Program {
public static void main(String[] args) {
InterfaceXYZ.InnerXYZ inner = new InterfaceXYZ.InnerXYZ();
}
}


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend

Previous Next vertical dots separating previous/next from contents/index/pdf Contents

  |   |