I'm trying to create a method that can exchange the location/reference of two class variables, but I can't change the reference of the class variable that is calling the method (this
), so I'm wondering is there any way to get around this.
public void exchange(Card x) {
Card y = this;
this = x; //this doesn't work
x = y;
}