python - Multiply string in Java -
this question has answer here:
in python can this: print("a" * 2);
output = aa
is there way in java same without loops?
try this:
string buildstring(char c, int n) { char[] arr = new char[n]; arrays.fill(arr, c); return new string(arr); }
arrays.fill()
standard api method assigns given value every element of given array. guess technically it'll looping 'inside', in order achieve this, perspective of program you've avoided looping.
Comments
Post a Comment