是否可以使用运算符在java中组合三个字符串?

时间:2018-03-07 18:58:37

标签: java

任何人都可以帮助连接java中的三个字符串吗?例如,如果有三个字符串a = this b = is c = march那么结果必须连接为“this is march”

2 个答案:

答案 0 :(得分:0)

您可以使用+运算符。

string result= a + b + c;

或做类似的事情

String a = new StringBuilder(b).append(c).append(d).toString();

答案 1 :(得分:0)

String result = a + " " + b + " " + c;

或另一种方式:

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

%s表示将被字符串替换的区域,该字符串由方法其余部分中的相应参数提供。