File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Difference between String objects and string buffer objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Difference between String objects and string buffer objects" Watch "Difference between String objects and string buffer objects" New topic
Author

Difference between String objects and string buffer objects

Venkat Ramsimha
Ranch Hand

Joined: Dec 28, 2004
Posts: 127
Hi Everybody,
I need to know the basic difference between 'String objects' and 'Stringbuffer objects'
can anybody explain within a program the basic functionality of the both objects?

tx&best regards
venkat
Salvador Cecilio
Ranch Hand

Joined: Dec 20, 2004
Posts: 41
Here's a short answer.

A string object contains a sequence of characters that cannot be changed. When you attempt to "modify" a String object, a new String Object is actually created. This is inefficient when the sequence of characters is frequently modified. The solution is to use a StringBuffer object so that changes in the sequence of characters does not require the creation of a new object.


SCJP 1.4 - 93%
SCWCD 1.4 - 89%
IBM FileNet 3.5 - Developer
IBM FileNet 3.5 - Administrator
 
GeeCON Prague 2014
 
subject: Difference between String objects and string buffer objects