Reputation: 8026
Dealing with a refactoring scenario, and wondering if there's a way to override "this" in java.
Basically, I would like to return an instance of another class when this is called.
Is this possible?
Upvotes: 2
Views: 974
Reputation: 2920
There is no way to override this
. Create an instance of the desired class and return that instead.
Test t = new Test();
public Test getTest() {
return this.t;
}
Upvotes: 3
Reputation: 1108
This is a fundemental of java (and many others). As stated in the comments the thing to do is create your 'that' class and return it.
Upvotes: 1