How do I format numbers like Cs printf()?
Java does not have any built in equivalent to C’s printf/sprintf/fprintf family of functions that specify the width and precision of numbers converted into strings. Since Java does not support variable length argument lists, it’s not possible to write exact equivalents for these functions. Instead the approach that must be taken is to convert one number at a time into a string according to a format specification, then write the resulting string onto the appropriate output stream. This is a more flexible solution, but it’s far from obvious. In Java 1.