java用新行合并两个字符串
现在,我有两条绳子
String str1="In the morning
I have breakfast
After";
String str2="In the afternoon
I have dinner
Before";
我想合并两个字符串以创建一个字符串,如下所示:
String strMerge="In the morning
In the afternoon
I have breakfast
I have dinner
After
Before"
我该怎么办
# 1 楼答案
希望您使用
\n
作为新行(如果没有,请将拆分设置为:str1.split("[ ]+")
):输出: