Results 1 to 6 of 6
  1. #1
    Cylab is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default How to get previous line rather than next?

    System.out.println();
    it gets next line for every output,
    but I do not wanna change line for some of em.
    What should I do?

    e.g.
    a
    b c d
    f h
    l

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Cylab View Post
    System.out.println();
    it gets next line for every output,
    but I do not wanna change line for some of em.
    What should I do?

    e.g.
    a
    b c d
    f h
    l
    Stacks are ideal for that purpose ...

    kind regards,

    Jos

  3. #3
    Cylab is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    <b>
    <a>i</a>
    </b>
    for every push method I need to change new line (I just push elements in tags, pop off it is same to peek elements). Any idea for getting following results like:
    b
    " "a-i

  4. #4
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Default

    First I don't understand ur problem? Can u be more clear.
    Now to ur 1st post,
    use : System.out.print();
    to get output in same line.

    -regards

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Prajin View Post
    First I don't understand ur problem? Can u be more clear.
    Indeed; if the OP wants some sensible answers s/he should post a sensible question. What was posted so far is unclear at best.

    kind regards,

    Jos

  6. #6
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    Prajin is correct in using print() for this purpose:
    Java Code:
    This code:
    System.out.print("hi, ");
    System.out.print("how ");
    System.out.println("are");
    System.out.print("you");
    System.out.print("?\n");
    System.out.print("Good, thanks!");
    
    Produces:
    hi, how are
    you?
    Good, thanks!
    However, if you are asking about changing an already printed line, you cannot do this. You must determine the string you want printed before printing it.

Similar Threads

  1. tracing java application line by line using netbeans
    By chandrasekhar123 in forum NetBeans
    Replies: 1
    Last Post: 08-03-2010, 02:46 PM
  2. Replies: 2
    Last Post: 07-02-2010, 02:20 PM
  3. Replies: 4
    Last Post: 09-10-2009, 10:18 AM
  4. Next and Previous Buttons
    By kbgriggs in forum New To Java
    Replies: 2
    Last Post: 08-12-2009, 02:08 PM
  5. Replies: 9
    Last Post: 04-07-2009, 03:51 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
  •