Click here to Skip to main content
15,891,689 members
Please Sign up or sign in to vote.
1.40/5 (3 votes)
See more:
What does the word 'this' in java means? Thanks in advance.


Example;

mSensorManager.unregisterListener(this);
Posted

This is a reference to the current object. For more info check here[^]
 
Share this answer
 
This Keyword is always refer to current instances of classes or you can say current object.
you can use this in any way as given below
a) you can use this to overcome to instance variable hiding.
b) you can use this to refer current object inside any method.
c) you can use this to pass object as a parameter to another methods.
d) you can use this to invoke another constructor in same class.

and for details you can navigate the given link
this Keyword[^]
 
Share this answer
 
So in this case, which of the four options is the word 'this' being used as?

a) you can use this to overcome to instance variable hiding.
b) you can use this to refer current object inside any method.
c) you can use this to pass object as a parameter to another methods.
d) you can use this to invoke another constructor in same class.



@Override
   protected void onPause(){
       if (theRegisteredSensor){
           theSensorManager.unregisterListener(this);
           theRegisteredSensor = false;
       }
       super.onPause();
   }
 
Share this answer
 
Comments
Dalek Dave 24-Nov-10 3:44am    
Good answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900