• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

modifiers to inner class  RSS feed

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • 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
  • 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, 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!