Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method local inner classes - conclusion

 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • 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?
 
Henry Wong
author
Marshal
Pie
Posts: 20997
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops...it should've been 'local member'!
Sorry for the mistake.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic