I am trying different combination of inner classes.I wonder that java gives you facility to write interface inside interface.It does not give me any compile time error. Can anybody tell me what is the use of this ?
public interface IA {
public interface IB{
}
}
This enables you to put the sub interface in a namespace that might make more sense than a different package. A good example of this from the Java API is the Map.Entry
interface. An Entry
only really makes sense in the context of something implements the Map
interface, so it is defined as an interface inside an interface.
Note that other than with inner classes, inner interfaces are always static, as Jesse Glick mentions in his answer to a related question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With