Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

this or _this

Status
Not open for further replies.

Krolsky

Programmer
Apr 16, 2002
20
DE
I am not sure if this is the apropriate place to ask this but I'm searching for a decent (or better) description about "this" and/or "_this".

I use it and I think it's got something to do with being a pointer to the object you use it on.

In my code I have a return statement like this:
return myCar._this();

now what I would like to know is what exactly is returned and what I can do with that.
In the rest of the code I have selected important things that might be needed to help me out:

Car myCar = new Car();

in the class Car there is a getSeat() that returns an object Seat. getSeat() should now return myCar._this().
 
Your code won't work as it is written. Remember, in Java, when you are executing code within a non-static method, you are doing so within the context of an object. 'this' is that object so you can use it to refer to instance variables or CTOR's directly:

public class Bar
{
private int x;

public void foo(int x)
{
this.x = x;
}
}

etc.

_this is NOT a method as in your example unless you have confusingly created a method with that name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top