• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question abt Method Local Class

 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider following code

This is an example of declaring an (non-anonymous) inner class within a method, i.e. yo( ). The rules of applying modifiers to this type of inner class is similar to that of local variables. You cannot marked the this type of inner class with the following modifiers : static, private, protected, public, transient, volatile, native, and synchronized. The only modifiers you are allowed to used on them are : final, abstract and strictfp (and of course without any modifiers at all).

Now My question is if we say "Rules which are applied to local method class
is same as rules applied to Local variable" Then how can we apply abstract and strictfp keywords to local method class.

Thanks
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my opinion abstract and trictfp are class modifiers. Anything that is method local other than a class is a variable declaration and initialization and/or a method call.
So a variable cannot have the modifiers: abstract and strictfp, anywhere.
Hence the reason.
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should read:

The rules of applying ACCESS modifiers to this type of inner class is similar to that of local variables.

Think about it. A method-local class differs from other types of classes in terms of SCOPING, which is related to ACCESS.

The modifiers "strictfp", "abstract" and "final" have nothing to do with SCOPING and ACCESS. "strictfp" is about floating point arithmatic. "abstract" and "final" are about SUBCLASSING.
 
reply
    Bookmark Topic Watch Topic
  • New Topic