• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Inner class

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seen below statement in one mock exame answer reasoning.
"Locale inner classes may not be declared coderanch, protected, private."
"Locale Inner classes are not associated with an instance of an outer(enclosing) class."
i think this statements is wrong. Becaus we can declare inner classes coderanch,protected,private, and static.
Please correct me if i am wrong.
can any one tell the difference between inner classes and Locale inner classes.
Thanks in advance....
Regards
Satish
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Both statements are right. A local inner class is one which is defined inside a method. A non-local inner class (or simlpy inner class) is one which is a member of a class.
A local inner class's scope is only inside the method containing it. So you can instantiate that class only inside that method. So, there is no question of local inner class being associated with the instance of the outer class.
It cannot be static, private, protected etc. I think it is because any member (for eg. variables) of method cannot static, private, protected etc. But it can be final ; so can the variables inside methods.
Hope this helps. Please correct me if I am wrong.
Milind
 
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic