Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Referencing Inner Class Methods or Variables

 
Thomas Markl
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Referencing Inner Class Methods or Variables
============================================
An method/variable of the instance inner class can only be invoked by a reference to the outer instance e. g.
Inner in1 = new Outer().new Inner();
There are two ways of referencing an inner class method/variable as I stated in the coding you can see down
there. Which way is the best to reference the inner class variable y?


 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These two code samples are entirely equivalent.
 
Thomas Markl
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I know that the functionality is entirely equivalent, but the coding to archieve this differs. So when apply simple method and when apply complex method?
Thomas
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code doesn't really differ. If you have a method that does nothing but invoke a constructor, you can just as well omit the method and call the constructor directly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic