Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

StringBuffer reset to null

Status
Not open for further replies.

itchyII

MIS
Apr 10, 2001
167
Hi! Can anyone tell me if there is a way that I can reset a StringBuffer to a null value after I have used it, so I can re-use the same StringBuffer further on in the program? Or do I have to release it and create a new one? If this is the case, I am not sure how to release it. I am new to Java but have experience with C/C++. I am looking for a simple way, nothing too in depth!

Thanks
ItchyII
 
try using the StringBuffer.Delete(int startIndex, int endIndex) method.
 
An example would be:
Code:
StringBuffer sb = new StringBuffer("test");
System.out.println(sb);
sb.delete(0,sb.length());
System.out.println(sb);
Wushutwist
 
That's exactly what I was looking for!
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top