如何重复字符串“n”在java中的时间? [英] How to repeat string "n" times in java?
本文介绍了如何重复字符串“n”在java中的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
类似这样的事情 -
我想能够重复一串字符串n次
字符串X,
用户输入= n,
5 = n,
输出:XXXXX
我希望这是有道理的...
(请尽可能具体)
解决方案
str2 = new String(new char [10])。replace(\0,hello);
/简单的方式重复在字符串中的Java / 4903603#4903603
I want to be able to repeat a string of text "n" times:
Something like this -
String "X", user input = n, 5 = n, output: XXXXX
I hope this makes sense... (Please be as specific as possible)
解决方案
str2 = new String(new char[10]).replace("\0", "hello");
note: this answer was originally posted by user102008 here: Simple way to repeat a String in java
这篇关于如何重复字符串“n”在java中的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文