Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

Using "StringBuffer" And "StringBuilder" Classes In JAVA

Share this post!
 Vote this!

Introduction

The instances of the String class represent a string that cannot be modified. If we do want to create modifiable strings because we are going to do lots of string manipulation, we should use the java.lang.StringBuffer and java.lang.StringBuilder classes.If we choose to do a lot of manipulations with String objects, we will end up with a lot of abandoned String objects in the String pool. Objects of type StringBuffer and StringBuilder can be modified over and over again without leaving behind a great effluence of discarded String objects.
A common use for StringBuffers and StringBuilders is file I/O when large, ever-changing streams of input are being handled by the program. In these cases, large blocks of characters are handled as units, and StringBuffer objects are the ideal way to handle a block of data, pass it on, and then reuse the same memory to handle the next block of data.  more...

0 comments:

Post a Comment