I dont think the object referred by s will be available for GC at LINE3 because it has the refernce, s, now also. An object will be available for GC, when it don't have any live references. In my opinion, it will be available for GC at LINE 4, ie, by the end of that method
An object is eligible for garbage collection when there is no direct or indirect reference to it.
In this case at Line 3 there is still a reference to the StringBuffer object. The object would be eligible for garbage collection when the program goes out of scope. If you want to make it eligible for GC before the main method goes out of scope make all the references to it null explicitly.
<b><i>Maya</i></b>
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad: