• Post Reply Bookmark Topic Watch Topic
  • New Topic

Use of (this) operator  RSS feed

 
omar salem
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to know how we use "this" operator....how is it related to the currently invoked object.....i would appreciate helping me...thanks
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'this' is a reference to the current object. Have a look at this example:

Note that there is a member variable 'name', but the argument to the constructor is also called 'name'. The argument hides the member variable inside the constructor. To reach the member variable 'name', you have to put 'this.' in front of it.
 
omar salem
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper....that really helped
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!