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 -

linux - phpmyadmin, neginx error.log - Check group www-data has read access and open_basedir -