Link to home
Start Free TrialLog in
Avatar of meow00
meow00

asked on

append things to String ...

Hello experts,

  I have a loop like:

  String myString = " ";
  for(int i=0; i<N; i++){
   myString += (String)i*10000; }

 the code becomes slower and slower when N gets larger ...
 is there any other better way (faster ways) to append things the the String ?

 thanks.  
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Keep in mind that StringBuilder is available only in Java 5, so if you have a prior version of Java, you need to stick to StringBuffer.