This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes  Conversion String concordinate  (using +) to StingBuffer Class are no longer needed in Java 1.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark " Conversion String concordinate  (using +) to StingBuffer Class are no longer needed in Java 1.5" Watch " Conversion String concordinate  (using +) to StingBuffer Class are no longer needed in Java 1.5" New topic
Author

Conversion String concordinate (using +) to StingBuffer Class are no longer needed in Java 1.5

Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
Hi,

Conversion String concordinate (using +) to StingBuffer Class are no longer needed in Java 1.5?. One of my friend is saying this to me.. I tried a simple example and i can still see the performance difference... is this statement is true.


My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Hi Mohammed,
Please CarefullyChooseOneForum next time. I'm moving your thread out of "Jobs Discussion".


[My Blog]
All roads lead to JavaRanch
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41065
    
  43
I'm confused because "+" is generally used in conjunction with String, not StringBuffer. Can you give an example piece of code of the technique you're talking about?


Ping & DNS - my free Android networking tools app
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

I don't know exactly what you mean with your question, but code that concatenates strings with + is still converted to operations with StringBuilder by the Java compiler in Java 5. Note that it's no longer using StringBuffer, but StringBuilder.

StringBuilder is almost the same as StringBuffer, except that it's not synchronized (similar to the difference between ArrayList and Vector). StringBuffer is a legacy class that should not be used anymore in favour of StringBuilder.

Maybe your friend read something about StringBuffer being obsolete since Java 5 and got confused with this.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conversion String concordinate (using +) to StingBuffer Class are no longer needed in Java 1.5
 
Similar Threads
Urgent Help Needed.
Difference of equals method in string and stringbuffer
String & StringBuffer
downsides omitting getContentPane()
Boxing n Auto boxing-marcus green