How to Append String In Java?

Ads
 

How to Append String In Java?

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

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

Ads









Related Tutorials/Questions & Answers:
How to Append String In Java?
How to append String in Java?
Advertisements
How To Append String In Java
MySQL Append String
Append a string to an existing file
Java2
cannot find symbol method append(String)
cannot find symbol method append(String)
In Java I have append to an existing string efficiently
how to write append file in Java
How to append text to an existing file in Java
Javah
MySQL Append String
Javap Tool application
How to split string in Java?
How to convert into to String in Java?
ModuleNotFoundError: No module named 'javax'
ModuleNotFoundError: No module named 'javax'
how to print String as pattern ?
How to trim string till indexof the string
How to display string or character
MySQL Append
How to convert String into java.util.Date
How to convert a String to an int?
How to Convert String to Date?
how to append data to XML file in proper format using JSP
Java append file
MySQL Append
Artifacts of javax
How to convert string to byte in Java
MySQL Append Data

Ads