public class Table { public static void main(String[] args) { final int COLUMN_WIDTH = 10; for (int x = 1; x <= 10; x++) { // print table row for (int y = 1; y <= 8; y++) { int p = (int)Math.pow(x, y); // convert value to string String pstr = "" + p; // pad with spaces while (pstr.length() < COLUMN_WIDTH) pstr = " " + pstr; System.out.print(pstr); } System.out.println(); } } }