I.e., in

class A {
    public String s;
}

and

A a1 = new A();
a1.s = "bla";
A a2 = new A();
a2.s = a1.s;
a1 = null;

will a1 be garbage collected or is the reference to a1.s permitting it from being collected (and I should rather do a deep copy, a2.s = new String(a1.s))?

Thanks a lot in advance!

Edit
Report