aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Use for nested interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Use for nested interfaces" Watch "Use for nested interfaces" New topic
Author

Use for nested interfaces

Bill Nelsen
Greenhorn

Joined: Aug 11, 2004
Posts: 27
I started to play around with nested interfaces, because I read that by definition they are static. So this is the trivial example that I arrived at,

interface A {
interface B {
void help();
}
}
class Base implements A.B {
public void help() { System.out.println("Help"); }
}

class Test {
static public void main(String[] args) {
A.B b = new Base();
b.help();
}
}

Since the nested interface is static, it requires this unusual notation (or at least I think that it does). I have a difficult time intuitively picturing what a static interface would look like. Is there a good use for a nested interface or is it just a feature (like interfaces that contain concrete classes), which is just there for completeness, but doesn't really serve a useful purpose??
~
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Nested interfaces also means interfaces defined within a class. In this article an example of such nested interfaces is given.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Bill Nelsen
Greenhorn

Joined: Aug 11, 2004
Posts: 27
Thanks for the link to a great article. I am reading all 3 parts of the article.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use for nested interfaces
 
Similar Threads
Interfaces
inner interface.........help me
INNER CLASS - Is it an error / JLS
nested interface
why protected methods are not allowed in a Interface