Can I multiply strings in Java to repeat sequences?

I have something like the following:

int i = 3;
String someNum = "123";

I’d like to append i “0”s to the someNum string. Does it have some way I can multiply a string to repeat it like Python does?

So I could just go:

someNum = sumNum + ("0" * 3);

or something similar?

Where, in this case, my final result would be:


Leave a Comment