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"
Asked
Active
Viewed 90 times
2 Answers
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
-
-
note that `a+b+c` is syntactic sugar for `new StringBuilder(a).append(b).append(c).toString()`. – Johannes Kuhn Mar 07 '18 at 19:20
0
String result = a + " " + b + " " + c;
Or a another way:
String result = String.format("%s %s %s", a, b, c);
The %s
s represent an area that will be replaced by a string, which is supplied by the corresponding argument in the rest of the method.

Antidisestablishmentarianism
- 81
- 3
- 11
-
1
-
My bad, I meant less annoying to type (for me). I fixed it. – Antidisestablishmentarianism Mar 07 '18 at 19:12