Best Practice to reset a StringBuffer var
I want to manage memory well but a little confused about resetting StringBuffer vars and it's impact
static public StringBuffer mySB = new StringBuffer("OK by me");
... processing code
Now I want to reset the value in mySB to "Too Bad";
Is it OK to do the following or is there a better way ?
mySB = new StringBuffer("Too Bad");
Thanks!
![scool.gif](http://forums.parallax.com/images/smilies/scool.gif)
static public StringBuffer mySB = new StringBuffer("OK by me");
... processing code
Now I want to reset the value in mySB to "Too Bad";
Is it OK to do the following or is there a better way ?
mySB = new StringBuffer("Too Bad");
Thanks!
![scool.gif](http://forums.parallax.com/images/smilies/scool.gif)
![scool.gif](http://forums.parallax.com/images/smilies/scool.gif)
Comments
but you have lost its reference.
Better way:
mySB.clear(); //clear the existing instance
mySB.append("Too Bad"); //append new string
regards peter