Solved

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

Posted on 2006-11-12
5
195 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Starting to learn JAVA, 7 59
ArrayIndexOutOfBoundException 9 66
stackato and cloud 4 65
reverse digits of a number using for loop 5 36
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

914 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now