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);

The sample code will create a string of 50 repeated ‘*’ characters.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: