Ran across a blind spot in trying to figure this out. I want to pad a string with n characters to the left (at the beginning) of the String. This is the code I have come up with padRight and padLeft but when I go run the program it doesn't do any thing. I know I need another class like maybe a StringTester but I don't know how to go about it. Could someone please help me out with this one?
public class StringUtils
{
public static String padRight(String s, int n)
{
return String.format("%1$-" + n + "s", s);
}
public static String padLeft(String s, int n)
{
return String.format("%1$" + n + "s", s);
}
}