worcester county court

I certainly can't see the benefit of repeating this basic lesson over and over across multiple questions and languages. Instead, we implement padding with format strings and the String.format method. @leftaroundabout: The purpose of a monospace environment is that there's a clear correspondence between printable character and displayed character position. Another way to do the left padding is to create a String with the desired length that contains only pad characters and then use the substring() method: And, finally, since Java 5, we can use String.format(): We should note that by default the padding operation will be performed using spaces. UtilsTest passed in my Java 6u45 and failed in Java 7u25. With BOM s, zero-width spaces, combining characters, confusables, etc... the best thing you can do is teach people to inspect their strings so they're equipped for this type of issue in the future: This string has some zero-width spaces: