Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How can i print rows 1 by 1 using System.out.println?

  1. #1
    Member
    Join Date
    Aug 2010
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can i print rows 1 by 1 using System.out.println?

    What i mean is I have the method
    public static void dumpData(PrintStream ps, Data data)
    which prints the results in seperate lines. I need to call this method dumpData(System.out, data) but each line should be in a row in a table. Is that achievable outside the method dumpData?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: How can i print rows 1 by 1 using System.out.println?

    which prints the results in seperate lines.
    Data goes on a new line when you output a newline character. You can keep all the output on one line by NOT outputting a newline character until you want the next output to go to the next line.
    The println() method always adds a newline character to the end of the data being printed.
    The print() method does NOT add a newline character.
    You can manually control where a newline character is added by using "\n" in the data.

  3. #3
    Member
    Join Date
    Aug 2010
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can i print rows 1 by 1 using System.out.println?

    Quote Originally Posted by Norm View Post
    Data goes on a new line when you output a newline character. You can keep all the output on one line by NOT outputting a newline character until you want the next output to go to the next line.
    The println() method always adds a newline character to the end of the data being printed.
    The print() method does NOT add a newline character.
    You can manually control where a newline character is added by using "\n" in the data.
    I think that there isn`t a solution to my problem. Thanks anyway. I should find a different approach.

Similar Threads

  1. Building Table of Specified Rows and Columns
    By wale89 in forum Java Servlet
    Replies: 1
    Last Post: August 3rd, 2010, 08:57 AM
  2. println class
    By javanub:( in forum Java Theory & Questions
    Replies: 9
    Last Post: May 18th, 2010, 01:18 AM
  3. System.out.println ("Hello world!")
    By ShaunB in forum Member Introductions
    Replies: 0
    Last Post: December 29th, 2009, 04:17 PM
  4. Need a loop for rows and columns
    By Ceasar in forum Loops & Control Statements
    Replies: 8
    Last Post: October 9th, 2009, 05:47 PM
  5. adding rows to coloumns. Netbeans
    By haygaurav in forum Java IDEs
    Replies: 1
    Last Post: April 1st, 2009, 03:16 PM