• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

modifiers to inner class

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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, coderanch, 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, coderanch, 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic