• 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

what can a static local class access ?

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
including variables and methods within its block and those belonging to the outer class ?
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
reply
    Bookmark Topic Watch Topic
  • New Topic