File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Nested Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Nested Interface" Watch "Nested Interface" New topic

Nested Interface

Asha Pathik
Ranch Hand

Joined: Feb 08, 2006
Posts: 143
Hi all,

Yesterday only I came across a piece of code in which there was an interface declared inside other interface. When I tried that code it seems the inner interface knows nothing about the outer interface's methods and variables.

My questions are:
  • Then what is the purpose of having such an interface?
  • It seems Map.Entry is an inner interface of Map interface. What is its use?

  • Kindly help,

    SCJP 1.5
    Stan James
    (instanceof Sidekick)
    Ranch Hand

    Joined: Jan 29, 2003
    Posts: 8791
    That structure was not necessary, but it does show you something about the designer's intent. With the given APIs, the only way you can get an instance of Map.Entry is from a Map, so it made sense to bundle the Map.Entry interface along with the Map interface. I've seen this organization other 3rd party packages, but not very often.

    A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
    I agree. Here's the link:
    subject: Nested Interface
    It's not a secret anymore!