如何串联Java中的字符串?

发布于 2021-01-29 20:09:49

strKeyword将根据循环被重复。如何将结果另存为新字符串。例如,如果工作“ hello”重复了两次,我现在将如何创建“
hellohello”作为一个全新的字符串。

for (int l = 0; l < newKeywordLength; l++) {          
    System.out.print(strKeyword);
}
关注者
0
被浏览
63
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。
    string newWord="";
    for (int l=0; l<newKeywordLength; l++){           
             newWord+=strKeyword;
    }
    System.out.print(newWord);
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看