What is an internal interface
An internal interface, also known as a nested interface, defines another interface within one interface. For example, the entry interface is defined in the map interface with the following code:
Public Interface Map { interface entry{ int getKey (); } void clear ();}
Why use an internal interface
Here are some strong reasons:
A logical grouping of interfaces that are used in the same place;
The embodiment of the encapsulation thought;
Nested interfaces can enhance the readability and maintainability of code;
An example of using an internal interface in the Java Standard library is java.util.Map and Java.util.Map.Entry. Here Java.util.Map is also used as a namespace. Entry is not part of the global scope, which means there is many other entities that is Entries and is not necessary Map ' s Entries. This indicates, Entry represents entries related to the MAP.
How the Inner class works
To figure out how the internal interface works, we can compare it to the inner class. An inner class can be thought of as a general method within the definition of an external class. Because a method can be declared as static and non-static, similar inner classes can also be declared as static and non-static. A static class is similar to a static method, and it can only access static member properties of an external class. A non-static method can access all member properties of an external class.
Because an interface is not instantiated, the internal interface is only meaningful if it is static. Therefore, by default, the internal interface is static, and you cannot manually add the static keyword.
Internal interface Example
Map.java
Public Interface Map { interface entry{ int getKey (); } void clear ();}
Mapimpl.java
Public class Implements Map { classimplements map.entry{ publicint GetKey () { return 0; } } @Override publicvoid Clear () { //Clear }}
Link: http://www.programcreek.com/2013/08/inner-interface-in-java/
Internal interface in "simple Java" Java