Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Gail Knight   on Jun 14 In Java Category.

  
Question Answered By: Haya Yoshida   on Jun 14

In response to the reply on using a StringBuffer instead of a '+' operator,
Why not use the concat(String str) method in the String Object api?

This would work the same, no?

String a="";
for(int i=0;i<20000;i++){
a = a.concat(i);
}

Please let me know which is better. I am a little curious now. Or is it
that a '+' operator and a concat method are exactly the same as in your
code1 example and the code2 example it still the better choice?

Share: 

 

This Question has 8 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on String Object Or get search suggestion and latest updates.


Tagged: