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

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -