File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Advantages of Nesting Interfaces ?

 
Murgan Sub
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at this code below
interface E {
interface G {
void f();
}
interface H {
void f();
}
void g();

}
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And?
What is exactly your question? Elaborate please.
 
Murgan Sub
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the advantages of nesting interfaces?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are very few examples of nested interfaces. A "well-known" one is for instance Map.Entry within interface Map (in java.util).
Some will say that nested classes (or interfaces) provide a better organization of your code and allow to avoid namespace pollution. It's more a matter of taste in my opinion.
Inner class Spec:
http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc.html
Inner class chapter from KM:
http://developer.java.sun.com/developer/Books/certification/certbook.pdf
Some articles on that topic:
http://www.javaworld.com/javaworld/javatips/jw-javatip50.html
http://c2.com/ppr/wiki/JavaIdioms/ImmutableInterface.html
http://www.dcs.ed.ac.uk/teaching/cs3/ipcs/APJ/apj9.pdf
[ February 11, 2002: Message edited by: Valentin Crettaz ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic