• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface can contain nested Interface ?  RSS feed

 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can interface contain nested interface , but why as per the definition of interface there will be no implemention !

So what is the purpose of nested interface in interface ?

interface test {

interface inner {
}

}


prabhat
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the java.util.Map with the static-interface java.util.Map.Entry as an example.
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i know it is used there ....is it meaningful to use or not ?
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course it is meaningful . . .
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface Map<K,V>
{
interface Entry<K,V> {
K getKey();

V getValue();

V setValue(V value);
}

}

It shows that interface containing interface actually provides data encapsulation.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!