Java printf using variable field size?

Declare an extra variable before using printf:

String format = "%" + fieldSize + "d";
System.out.printf(format, yourVariables);

(this is the first solution I found from a web search)

Leave a Comment