devxlogo

October 3, 2017

Easily Create a String of Repeated Characters

Use the string class’s constructor to specify the character and the number of times you want it to be repeated. Listing 1. Repeat String Characters String repeatedCharacterString = new String(‘*’,50);