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 modifiers to inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "modifiers to inner class" Watch "modifiers to inner class" New topic
Author

modifiers to inner class

Venkat Ramsimha
Ranch Hand

Joined: Dec 28, 2004
Posts: 127
the only modifiers you can apply to a method-local
inner class are abstract and final. (But of course, never both of those at the same time as with any other class or method.)
WHY we shud not HAVE OTHER ACCESS MODIFIERS FOR INNER CLASSES

hi all,
can anybody provide the explanation

thanks,
venkat
Joe Sondow
Ranch Hand

Joined: Apr 10, 2005
Posts: 195
The modifiers that you CAN use are abstract, final, and strictfp.

The other modifiers that exist but cannot be used on method-local inner class (also known as "local classes") include the following:
transient, volatile, native, static, public, private, protected

For a method-local inner class...
You can't use transient or volatile because they only apply to instance variables.
You can't use native because that only applies to methods.
You can't use static, public, private, or protected because those have no meaning for something declared inside a method. (Ask yourself what it would mean to use any of those on a local class.) All of these 4 keywords are meant only to modify a member of a class, but a local class cannot be a member of a class.


SCJA 1.0 (98%), SCJP 1.4 (98%)
 
jQuery in Action, 2nd edition
 
subject: modifiers to inner class
 
Similar Threads
inquisition question
Class Acces
Access modifier for members of method local inner class.
Inner Class Question
Modifiers for anonymous inner classes and static nested classes