You create the stringbuffer object just to use , why care the init size 這樣不是更好嗎?可以節省內存啊?為什么別人不這么產生對象呢
Object is created and referenced by the variable . at that point the 該方法執行一次,一個新的stringbuffer將被創建并且被sb變量引用。
Object , and now it can be garbage collected . this elimination of the reference is equivalent to nulling the 于是不再有對該stringbuffer對象的引用,現在它就可以被當作垃圾收集了。
Object created in the first line . as long as the method is executing , the reference to the 當該方法執行時,運行時棧保留了一個對stringbuffer對象的引用,這個對象是在程序的第一行產生的。
Is being held onto by the application for much longer than it needs to be - possibly forever if no one ever calls 也就是說,這個死亡的stringbuffer對象被程序保留的時間比它實際需要保留的時間長得多如果再也沒有對該scopingexample方法的調用,它將會永遠保留下去。