top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Can we use "this" keyword without creating object of class in java?

+1 vote
100 views
Can we use "this" keyword without creating object of class in java?
posted Sep 12, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Yes, because the this object reference can be used inside any non-static method to refer to the current object

The common uses of the this reference are:
To pass a reference to the current object as a parameter to other methods

someMethod(this);

To resolve name conflicts Using this permits the use of instance variables in methods that have local variables with the same name

answer Sep 13, 2014 by anonymous
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...