Which is the best way to use for String concatenation in
Java?

Answer Posted / leo zhao

Hi Manasa,

You can use append to concatenate more than 2 strings, such as

StringBuffer str = new StringBuffer("Stanford ");
str.append("Lost!!").append(" again.");

Is This Answer Correct ?    18 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the impact of declaring a method as final?

763


How do you remove duplicates in java?

749


Difference between Preemptive scheduling vs. Time slicing?

796


What is string [] java?

738


What is api in java?

757


What does system out println () do?

784


What are the differences between the constructors and methods?

815


What is the difference between the jdk 1.02 event model and the event-delegation model introduced with jdk 1.1?

858


How does class forname work in java?

713


What is starvation?

927


What do you mean by formatting?

742


How do you convert an int to a string in java?

800


What is the benefit of inner / nested classes ?

730


How can we avoid including a header more than once?

799


What are streams?

851