String s1 = new String("a");
String s2 = new String("b");
for (int i=0; i<100; i++)
{
s1 = s1 + s2;
if (i%3 == 0)
s2 = s2 + s2;
}
Suppose a mark-and-sweep garbage collector was activated after the loop had
executed three times. Describe its likely operation.
Thanks a lot
m******t 发帖数: 2416
2
I would remove the last sentence above to make it look less like
a homework question.
【在 y**e 的大作中提到】 : String s1 = new String("a"); : String s2 = new String("b"); : for (int i=0; i<100; i++) : { : s1 = s1 + s2; : if (i%3 == 0) : s2 = s2 + s2; : } : Suppose a mark-and-sweep garbage collector was activated after the loop had : executed three times. Describe its likely operation.