Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Java

Idiom #215 Pad string on the left

Prepend extra character c at the beginning of string s to make sure its length is at least m.
The length is the number of characters, not the number of bytes.

while (s.length() < m) s = c + s;
s = s.PadLeft(m, c);

New implementation...