aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what can a static local class access ? 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 "what can a static local class access ?" Watch "what can a static local class access ?" New topic
Author

what can a static local class access ?

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
including variables and methods within its block and those belonging to the outer class ?
Nasir Khan
Ranch Hand

Joined: Nov 04, 2000
Posts: 135
As much I know a local inner class can't be static also it can't has access modifiers public,protected or private, it can only be
final or abstract..
umang bhartia
Ranch Hand

Joined: Sep 29, 2000
Posts: 60
I agree with Nasir,
Local inner class can't be explicitely declared as static, if the method in which it is declared is static then it implicitely becomes static. Even u cant provide any access modifiers. These classes can only access final variables of the enclosing method and r having full accessability for all the variables and method outside the enclosing method ie in that class.
For a local inner class which is inside a static method the rule is that it can only access final variables of the enclosing method, and static variables and method of the class. However u cant declare any static variables in a local inner class.
Please correct me if i m wrong some where.
Balamurugan Kandasamy
Greenhorn

Joined: Dec 03, 2000
Posts: 19
For life to be easy, down goes the rule from Mughal & Rasmussen.
----------------------------------------------------------------
Entity Declaration Direct access Ability to
context to Context define members
----------------------------------------------------------------
Non-static As non-static All members Only
inner class class member in enclosing non-static
context
Local class In block with All members Only
(non-static) non-static in enclosing non-static
context context
+
local final
variables.
Local class In block with Static members Only
(static ) static in enclosing non-static
context context
+
local final
variables.

----------------------------------------------------------------
Thanks
MKBala...
Balamurugan Kandasamy
Greenhorn

Joined: Dec 03, 2000
Posts: 19
Oops sorry about the scattered collection :-)
Hopefully the following turns user friendly.
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="Microsoft Word 97">
<TITLE>Entity</TITLE>
</HEAD>
<BODY>

Entity Context Declaration Direct access to Context Ability to define members
Non-static inner class As non-static class member All members in enclosing context Only non-static
Local class (non-static) In block with non-static context All members in enclosing context + local final variables. Only non-static
Local class (static) In block with static context Static members in enclosing context + local final variables. Only non-static



</BODY>
</HTML>

 
jQuery in Action, 2nd edition
 
subject: what can a static local class access ?