Any suggestions on making toString printouts nicely?

im trying to print out info from an array by doing
for(int i = 0; i < array.length; i++)
     System.out.println(array)
but everytime the array[5] gets printed out its like this:
Name                         Age                             Birthday
John Doe                    18                                0/00/00
John        18            0/00/00
....the way im printing it out is by creating a table with /t that i did already in my toString method from the class with getName(), getAge() and such. so its evenly spaced but whenever the name being printed out is short the spacing or /t moves up causing it not to be aligned. any suggestions on how to fix it or if you had this problem also are there any other ways to print it out and have it aligned like a table.?

You should be able to adapt this
public class PrintInColumns {
    public static void main(String[] args) {
        /* Prints to DOS/cmd window in columnar format using
           System.out.println. If you don't need 5 columns, just
           set the unused dataN values to the null string "".
           stBuf StringBuffer is initialized to 75 spaces.
           This can be changed if desired.
        // Change ColN to your desired start column
        final int Col1 =  0;  // data1 start column
        final int Col2 = 15;  // data2 start column
        final int Col3 = 30;  // data3 start column
        final int Col4 = 45;  // data4 start column
        final int Col5 = 60;  // data5 start column
        String s = "                                                                           ";
        StringBuffer stBuf = new StringBuffer(s);
        // To print multiple lines, create a loop that encloses the
        // code below this point.
        // Convert all variables to strings and place them in the
        // following lines
        String data1="Hotshot";
        String data2="Programmer";
        String data3="(800)555-1212";
        String data4="Big Co., Inc.";
        String data5="";
        stBuf = ((((stBuf.replace(Col1, data1.length() + 1, data1)).
                      replace(Col2, Col2 + data2.length() + 1, data2)).
                      replace(Col3, Col3 + data3.length() + 1, data3)).
                      replace(Col4, Col4 + data4.length() + 1, data4)).
                      replace(Col5, Col5 + data5.length() + 1, data5);
        System.out.println(stBuf);
}

Similar Messages

Maybe you are looking for

  • How to send smartform output in body of email?

    Hi all , I have to send smartform output in body of email (not as an attachement in mail) .PLease help me in this regard. Thanks, Ananth S.

  • How to implement validations in message mapping?

    Hi experts, I have a simple requirement: I have a simple synchronous scenario: SOAP -> XI -> RFC In a message mapping, one of the fields in the source message is of type String. However, the target application (RFC) does not expect a non-numeric char

  • How to see status of emails stopped in queue

    Hello, I'd like ask you how is possible define reason of non-deliveriyng mail mesage. Below is my analyses: 1. list of all messages in queue (similar aoutput as mailq from *nix like systems) (Machine esa1.DOMAIN.XYZ)> showrecipients all Showing messa

  • Camera raw and elements 4.0 on a mac

    I run elements 4 (version 4.0 according to the 'about elements' box) on a power pc mac running Tiger 10.4.9. I've downloaded camera raw 4.1 and installed it as per the adobe instructions into the 'file formats' folder, removing the previous version o

  • I no longer have favicons in address bar (awesome bar)

    Firefox 14.0.1 I no longer have favicons in address bar (awesome bar): All that shows is a a generic graphic(globe?) that is grayed out. I do however still have fevicons in my bookmarks list. Thanks for your help!