Produce tables with the columns lining up in Java
Description
The following code shows how to produce tables with the columns lining up.
Example
// ww w.j a v a 2 s . co m
import java.util.Formatter;
public class Main {
public static void main(String args[]) {
Formatter fmt;
for(int i=1; i <= 10; i++) {
fmt = new Formatter();
fmt.format("%4d %4d %4d", i, i*i, i*i*i);
System.out.println(fmt);
}
}
}
The code above generates the following result.