| Author |
Nested Interfaces
|
Neil S Staish
Greenhorn
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
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
Please read the following discussion: http://www.coderanch.com/t/236382/java-programmer-SCJP/certification/Inner-Interfaces-vs-Nested-Interfaces You can also do a search in this forum with the keywords "nested interface".
|
SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[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
|
 |
 |
|
|
subject: Nested Interfaces
|
|
|