-5

can anyone help to concatenate three strings in java? For example, if there are three strings a=this b=is c=march then the result has to be concatenated as "this is march"

Gold Win
  • 7
  • 1
  • 7

2 Answers2

0

You can use + operator for this.

string result= a + b + c;

or do something like this

String a = new StringBuilder(b).append(c).append(d).toString();
Fatima Khan
  • 23
  • 2
  • 5
0
String result = a + " " + b + " " + c;

Or a another way:

String result = String.format("%s %s %s", a, b, c);

The %ss represent an area that will be replaced by a string, which is supplied by the corresponding argument in the rest of the method.