×

Loading...

question about java garbage collector

Consider the following code:
Public void method(String s)
{
String a,b;
a= new String( "Hello");
b= new String("Goodbye");
System.out.println(a+b);
a= null;
a=b;
System.out.println(a+b);
}

Where the garbage collector will run the first time?
In line "a=null" or " a=b"?
I think it will run in "a = null" at first, then "a=b".
Report

Replies, comments and Discussions: