Repeat a char for a number of times

I wasn’t aware there is a constructor for the String type that allow to insert the number of times we want a character to be repeated:

//expected: "AAAAA"
String result = new String('A', 5);

No Comments

You can leave the first : )

Leave a Reply

Your email address will not be published. Required fields are marked *