• 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

Method local inner classes - conclusion

 
Ranch Hand
Posts: 358
Firefox Browser Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inner classes are like a full fledged member of the enclosing class.
Similarly, can we conclude that a method-local inner class is like a local variable? Further, can we treat it like a local variable?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Similarly, can we conclude that a method-local inner class is like a local variable? Further, can we treat it like a local variable?



Not sure what you mean by treating a inner class like a local variable. One is a class definition and the other is a reference variable. You can certain assign an instance of an method inner class to a local variable, but you can also assign this instance to a instance or class variable too (Although, in these later cases, you will need to hold it in a super class to the inner class, as the inner class type will not be in scope).

Henry
 
Faisal Ahmad
Ranch Hand
Posts: 358
Firefox Browser Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops...it should've been 'local member'!
Sorry for the mistake.
 
reply
    Bookmark Topic Watch Topic
  • New Topic