Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

assign outer class variable a value from inner class

 
Ronnie Phelps
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can I assign an outer class variable a value while I'm in the inner class...
this.name = "whatever"
doesn't work because this refers to the inner class.
 
Barry Andrews
Ranch Hand
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the variable is global, you don't have to do anything but assign the variable. The inner class knows about the outer class variables.

Barry
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ronnie Phelps:
how can I assign an outer class variable a value while I'm in the inner class...
this.name = "whatever"
doesn't work because this refers to the inner class.

use OuterClassName.this.name = "whatever"
 
Ronnie Phelps
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ilja that worked...Thanks!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic