String with specified number of chars

  • Thread starter Thread starter Arbajram
  • Start date Start date
A

Arbajram

Hi,

The question is: How to create a string containing specified nr. of (same)
characters?

I guess the question is quite trivial but I still don't know the answer :)

Thx in advance
Armin
 
String s = new String('o', 4);
This will repeat char 'o' 4 times & will return 'oooo'

Does this help ?

Kalpesh
 
Hi

Use a PadLeft or a PadRight methods which are available to all string objects. That will help you in creating a string with specified no. of same characters
 
Back
Top