aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Is there something called 'inner interface'? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Is there something called Watch "Is there something called New topic
Author

Is there something called 'inner interface'?

Aakash Goel
Ranch Hand

Joined: May 26, 2008
Posts: 198
Inner classes exist. Why not inner interfaces?


SCJP 5 95%
SCJP FAQ | SCJP Mock Tests | SCJP Tipline | Generics
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

Did you try to create an interface within interface or class??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Aakash Goel
Ranch Hand

Joined: May 26, 2008
Posts: 198
Ankit Garg wrote:Did you try to create an interface within interface or class??


yeah, they do get created.

also, Set is an interface and so is Collection.

But nowhere in K&B is a mention of innner interfaces.

So, I thought probably they are not inner interfaces after all.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

there are inner interfaces but maybe nothing is asked about them in SCJP that's why nothing about them is given in K&B ...
Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331
Aakash Goel wrote:


So, I thought probably they are not inner interfaces after all.


They are not. Set is an interface that extends from Collection interface and its just a sub-interface... Its not an interface within another interface. From the specs here I see that Sun calls an interface within another interface as a "nested interface" I guess this nesting of an interface in another has only to do with some namespace resolution...


Blog
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Vishwanath brings up an important point. There is a rather complicated difference between a "nested class" and an "inner class"... I'm not going to try to explain it because I don't remember it correctly, but you might want to review that. Then it's quite likely that "inner interface" and "nested interface" would be the same concepts.
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452




you can find questions related to inner ineterfaces too in Dan Chilosam's book.

avi sinha


SCJP 5.0 SCWCD 5.0
Vlado Zajac
Ranch Hand

Joined: Aug 03, 2004
Posts: 245
The difference between "inner" and "nested" is that only non-static nested class is called "inner class" (static nested class is not an inner class).

Nested interfaces are always implicitly static so inner interfaces does not exist.
 
Consider Paul's rocket mass heater.
 
subject: Is there something called 'inner interface'?