Solved

y wasn't the functionality of stringbuffer included in string itself ?

Posted on 2006-11-12
5
206 Views
Last Modified: 2013-12-29
like doing
S + S + S + S + S + S + S
where S = string takes more time than the case where S = stringbuffer. Why wasnt the overloading of + for string itself made efficient ?
[Assuming thats the No.1 case for using stringbuffer - atleast I didnt use stringbuffer for any other purpose]
0
Comment
Question by:letsbedecent
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 84 total points
ID: 17928175
Basically becuase String's are immutable objects
0
 
LVL 6

Assisted Solution

by:valipotor
valipotor earned 83 total points
ID: 17928396
The Java language provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings. String concatenation is implemented through the StringBuffer class and its append method. String conversions are implemented through the method toString, defined by Object and inherited by all classes in Java. For additional information on string concatenation and conversion, see Gosling, Joy, and Steele, The Java Language Specification.

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html

valipotor
0
 
LVL 5

Assisted Solution

by:kannan_ekanath
kannan_ekanath earned 83 total points
ID: 17929420
If you wonder what an Immutable object is and why it enhances performance etc, kindly read these links,
http://www.javapractices.com/Topic29.cjp (Why you would need it)
http://en.wikipedia.org/wiki/Immutable_object (The definition)
http://www-128.ibm.com/developerworks/java/library/j-jtp02183.html (IBM article saying when you want to mutate)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question