高手请进: gabbage collection problem# Java - 爪哇娇娃
y*e
1 楼
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
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