java多行字符串怎么连接起来
lewis
2016-10-19
19次阅读
在Java中,可以使用加号(+)运算符将多行字符串连接起来。例如:
String str1 = "Hello, ";
String str2 = "world!";
String combinedString = str1 + str2;
System.out.println(combinedString);
另一种方法是使用StringBuilder类来连接多行字符串。例如:
StringBuilder sb = new StringBuilder();
sb.append("Hello, ");
sb.append("world!");
String combinedString = sb.toString();
System.out.println(combinedString);
这样就可以将多行字符串连接起来并输出结果。

发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。