Results 1 to 6 of 6
  1. #1
    helloworld is offline Member
    Join Date
    Sep 2008
    Posts
    11
    Rep Power
    0

    Default how to print out lines in a table- like form?

    May I know how to print out lines of text side by side, and aligned? Like this:

    Time: 3pm Date : 24/6/04
    Wins: 24 Losses: 34
    Weight: 50kg Height: 2.50m

    Thank you.

  2. #2
    chango77745 is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    If there are methods to the data, please just fill in my data with the methods.

    I don't know of any other ways other than
    System.out.println("Time: " + object.getTime() + "Date" + object.getDate());

    If you type that in using your methods instead of the ones I made up of course, you will get that exact format.

  3. #3
    chango77745 is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    I made one mistake with the date. It should read " Date: "

    there must be a space after the first quote because if there is not one, it will come together with the other data

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    You might also want to look at the method format in the String Class API docs.

  5. #5
    chango77745 is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    OOOORRRRRR
    Perhaps you can make a toString method to always have it in that format and you will just have to call the toString method instead of writing System.out.println for every object you create

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. Replies: 6
    Last Post: 11-28-2008, 07:55 AM
  2. enctype=multipart/form-data with form data in struts
    By vk_satheesh in forum New To Java
    Replies: 0
    Last Post: 09-19-2008, 01:48 PM
  3. How to print selected items in a SWT table
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:30 PM
  4. Print the text file and print preview them
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 12:04 AM
  5. how to edit lines.
    By jason27131 in forum New To Java
    Replies: 1
    Last Post: 08-01-2007, 05:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •