首页 > 代码库 > repeat a string in java

repeat a string in java

if I want to repeat "hello" four times as a new string-> "hellohellohellohello". I can:

return new String(new char[4]).replace("\0", "hello")

 

repeat a string in java