Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

this keyword?

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
well the keyword this is used to point at the current object, right?

can anone ber more precise on this???
 
fred rosenberger
lowercase baba
Bartender
Posts: 12146
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean by more precise?

It's similar to me writing a paper and using the word 'my' before 'arm'. the sentence 'arms are tattooed' has a different meaning than 'my arms are tattooed'. using the word 'my' indicates WHICH arms are being talked about.
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it by default?

whenever we write a simple hello world program...
(Sir, Huge fan of you and kathys sierra's(including many more cant memorize all the names) SCJP6 Book)
 
fred rosenberger
lowercase baba
Bartender
Posts: 12146
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is what by default what?

and what does it have to do with a hello world program?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Hegde wrote:
(Sir, Huge fan of you and kathys sierra's(including many more cant memorize all the names) SCJP6 Book)


Yes, fred, when are you coming out with a new one?
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The this keyword is a built-in feature of the Java language. So it is always there to be used, not sure if this is what you mean by default?

Hunter
 
fred rosenberger
lowercase baba
Bartender
Posts: 12146
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest Friedman-Hill wrote:
Vishal Hegde wrote:
(Sir, Huge fan of you and kathys sierra's(including many more cant memorize all the names) SCJP6 Book)


Yes, fred, when are you coming out with a new one?


No...they meant they are a huge fan of me...and also a huge fan of Kathy's book. Perfectly logical.
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Hegde wrote:Is it by default?


If I understand you correctly, it is optional in certain situations. For example, if you have a class-level field called "foo", you can access this field in a method with or without using "this", so it's optional.



However, if you also have a variable in your method with the same name, you must use "this" in order to refer to the class-level field.


You see this sort of thing a lot in setter methods, where the method parameter usually has the same name as the field.
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:
Ernest Friedman-Hill wrote:
Vishal Hegde wrote:
(Sir, Huge fan of you and kathys sierra's(including many more cant memorize all the names) SCJP6 Book)


Yes, fred, when are you coming out with a new one?


No...they meant they are a huge fan of me...and also a huge fan of Kathy's book. Perfectly logical.


Lucky to be one of the members of this forums

thnks i think i am getting concepts clear of this method
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic