Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Nested Interface

 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
     
    Stan James
    (instanceof Sidekick)
    Ranch Hand
    Posts: 8791
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic