class Test { public static void main(String[] agrs) { String[] person = new String[20]; String pername = "Peter"; person[0] = pername; pername = null; System.out.println(person[0]); // prints " Peter " on screen System.out.println(pername); // no content in pername. prints " null " } } will the pername object eligible for garbage collection ?
i think its eligible because the person[0] contains " Peter " and person[0] doesnt not refer pername anymore .