File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Nested Interfaces 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 "Nested Interfaces" Watch "Nested Interfaces" New topic

Nested Interfaces

Neil S Staish

Joined: Mar 24, 2003
Posts: 11
We often talk about nested classes. Does anyone have any tips/notes/commentary on nested interfaces (interfaces inside classes and interfaces)? :roll:
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
Please read the following discussion:
You can also do a search in this forum with the keywords "nested interface".

[Blog] [Blogroll] [My Reviews] My Linked In
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
(1) Interfaces declared inside a class or other interface are always implicitly static.
So what? This fact is not particularly useful, except that inner classes may not declare static things (static initializers, static fields, static methods, static nested classes, or interfaces).
Inner classes may not declare interfaces. Top-level classes, static member classes and interfaces may declare interfaces.
(2) Interfaces declared in classes can have private, default, protected or public access. Interfaces declared in interfaces are implicitly public.
(3) Static nested types serve as a structuring and scoping mechanism for logically related types.
Sources: JLS 8.1.2, 8.5, 9.5, The Java Programming Language 5.1, 5.6
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Member interfaces are always implicitly public and static (these modifiers are allowed but are unnecessary), abstract (use is discouraged) and can be declared strictfp. Furthermore, interfaces which are class members can be declared protected or private.
Member interfaces, being implicitly static, cannot be declared in non-static nested classes.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
I agree. Here's the link:
subject: Nested Interfaces
jQuery in Action, 3rd edition