Create a String of Repeating characters

By [)ia6l0 iii

Create a String of Repeating Characters using the String class's Overloaded Constructor

The String class constructor provides us an interesting overloading constructor with which we can create a string of repeated characters with ease. See the Code
snippet below :

String repeatedCharacterString = new String(""~"",45);

The above code would create a string consisting of the character "~" 45 times.

Create a String of Repeating characters  (1216 Views)