OK, here is the thing. I have multiple pointers to an object and I want to remove both of them. I have simplified it, below, so don't bother asking why on earth I would try the thing below :)
String first = "ASSIGNED";
String second = test;
second = null;
System.out.println(first);
In the example above, the output still results in "ASSIGNED". However, I want first to be no longer assigned. In the example above, it is easy, by setting it to null, but in my real example, this is not possible (first being passed into a method, where I want to remove the assingment).
EDIT:
So, I guess the question is, if it is possible to remove all pointers to a given object.
Apparently it was a bit vague what I was asking, so let's try to give a better example:
String first = "Assigned";
doSomethingAndRemove(first);
public void Remove(String string) {
//Do something
//...and remove
string = null;
}
The thing is that first still is referencing to "Assigned"... But from what I read in the answers so far, there is no way around this?