Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to Append String In Java?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Java Coder
How to Append String In Java?
1 Answer(s)      10 months ago
Posted in : Java Beginners


How to write program in in Java for appending to a String? How to Append String In Java?

What is the best way to do this?

Thanks


Advertisement
View Answers

December 24, 2013 at 5:05 PM


Hi,

The best best to append to a string is to use the StringBuilder class. Check the example at Appending String in java.

You can also use the String.concat(String s) method:

  String str = "String 1";
  str = str.concat(" String 2");

Check the tutorial for performance comparison at Appending Strings - Java Tutorials.

Thanks



Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com