Redian新闻
>
高手请进: gabbage collection problem
avatar
高手请进: 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
avatar
m*t
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.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。