File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why private interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why private interface" Watch "why private interface" New topic
Author

why private interface

lee nelson
Greenhorn

Joined: Sep 25, 2000
Posts: 2
hi guys,
Can any one tell me what's the use of an private and
protected interface
Ramesh Donnipadu
Ranch Hand

Joined: Sep 16, 2000
Posts: 100
Top level (package level) interfaces are public by default. This is trye even if you don't explicitly define any modifier. You can't define private/protected interfaces at package level.
However, interfaces defined inside a class can have any accessibility including protected and private. Let us see where these can be used.
Supposing A be top level class and IFace be inner interface defined with private modifier. Then all inner classes defined inside class A can inherit IFace. Subclasses of A cannot define inner classes that implement IFace.
With protected modifier subclasses of A can define inner classes which can implement IFace.
-Ramesh
 
 
subject: why private interface