public String toString() {
Node temp = head;
StringBuilder value = new StringBuilder();
while (temp != null) {
value.append(temp.toString());
temp = temp.next;
}
return value.toString();
}
Best Performance With String Concatenation
Page 1 of 12 Replies - 140 Views - Last Post: 21 April 2011 - 01:17 PM
#1
Best Performance With String Concatenation
Posted 21 April 2011 - 11:24 AM
Hey guys, I have a project that I'm working on where I have to traverse through a linked list of strings and concatenate all of the strings together. Now, I know that strings are immutable and really slow, so I was wondering if there was a way that I could improve my performance. I did some research and came across the StringBuilder class, but I'm still curious if there is a faster way.
Replies To: Best Performance With String Concatenation
#2
Re: Best Performance With String Concatenation
Posted 21 April 2011 - 12:23 PM
That may be cool, have you tried it to see if it does what you want?
I the issue is concatenating string, try these documentation and pages:
Class String
String
I the issue is concatenating string, try these documentation and pages:
Class String
String
This post has been edited by smohd: 21 April 2011 - 12:30 PM
#3
Re: Best Performance With String Concatenation
Posted 21 April 2011 - 01:17 PM
The StringBuilder is your best way of concatenation. If you are working with multiple Threads, stick with StringBuffer, as it is Thread-safe.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|