This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question abt Method Local Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question abt Method Local Class" Watch "Question abt Method Local Class" New topic
Author

Question abt Method Local Class

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
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
Suhas Wadadekar
Ranch Hand

Joined: May 16, 2006
Posts: 95
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.
Douglas Chorpita
Ranch Hand

Joined: May 09, 2006
Posts: 97
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.


SCJP 1.4 - 95%
 
wood burning stoves
 
subject: Question abt Method Local Class