Why is it, that when I add an object, to my ArrayList, which Should be passing it a Reference to the object, then I make the object equal to null, it outputs perfectly fine.
    ArrayList<Test> testList = new ArrayList<>();
    Test test = new Test();
    System.out.println(test);
    testList.add(test);
    for(Test t : testList)
    {
        System.out.println(t);
    }
    test = null;
    for(Test t : testList)
    {
        System.out.println(t);
    }
The test constructor goes as:
int x = 0;
Test()
{
    x = 50;
}
public String toString()
{
    return x + "";
}
Yet, the output is 50, 50, 50 instead of 50, 50, null
 
     
     
    