I am a new to java coming from python. I am wondering how I can multiply a string in java. In python I would do this:
str1 = "hello"
str2 = str1 * 10
string 2 now has the value:
#str2 == 'hellohellohellohellohellohellohellohellohellohello'
I was wondering what the simplest way is to achieve this in java. Do I have to use a for loop or is there a built in method?
EDIT 1
Thanks for your responses I have since found an elegant solution to my problem:
str2 = new String(new char[10]).replace("\0", "hello");
note: this answer was originally posted by user102008 here: https://stackoverflow.com/a/4903603