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
Java2
Append a string to an existing file
cannot find symbol method append(String)
cannot find symbol method append(String)
In Java I have append to an existing string efficiently
String Buffer insert and append example
how to write append file in Java
Javah
How to append text to an existing file in Java
MySQL Append String
Javap Tool application
ModuleNotFoundError: No module named 'javax'
ModuleNotFoundError: No module named 'javax'
How to split string in Java?
How to convert into to String in Java?
MySQL Append
how to append data to XML file in proper format using JSP
how to print String as pattern ?
How to display string or character
How to trim string till indexof the string
How to convert String into java.util.Date
How to convert a String to an int?
How to Convert String to Date?
Java append file
Artifacts of javax
MySQL Append
MySQL Append Data

Ads