
-----------------------------------
Prince Pwn
Tue Jan 12, 2010 5:48 pm

printf Table
-----------------------------------

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mypkg;

/**
 *
 * @author  Prince Pwn
 * @date    1/12/2010
 */

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String

This prints a table but it's not nicely formatted. I tried using printf but I'm not sure how I can do the squared and cubed with printf. Any ideas?

-----------------------------------
DemonWasp
Tue Jan 12, 2010 7:09 pm

RE:printf Table
-----------------------------------
First, remember that System.out is just a member of the System class. That should lead you to the out is PrintStream? Clicking on that leads you to printf methods, one of which supports a Locale; since you don't have one, click on the other, which takes you to System.out.printf ( "%d\t%d\t%d\n", (i), (i * i), (i * i * i) ); . Notice how the number of %d entries matches the number of integers I intend to output.
