1. public void countDown()
2. {
3. for( int i = 10 ; i >= 0 ; i-- )
4. {
5. String tmp = Integer.toString( i );
6. System.out.println( tmp );
7. }
8. System.out.println("BOOM!");
9. }
When the program reaches line 8, how many of the String objects created in line 5 are eligible for garbage collection? Assume that the System.out object is not keeping a reference.
答案为什么是10啊,tmp引用不是在第8行已经消失了么,为什么不是11呢?
2. {
3. for( int i = 10 ; i >= 0 ; i-- )
4. {
5. String tmp = Integer.toString( i );
6. System.out.println( tmp );
7. }
8. System.out.println("BOOM!");
9. }
When the program reaches line 8, how many of the String objects created in line 5 are eligible for garbage collection? Assume that the System.out object is not keeping a reference.
答案为什么是10啊,tmp引用不是在第8行已经消失了么,为什么不是11呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货