在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);
这样就可以将多行字符串连接起来并输出结果。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:c语言如何把字符串连接起来