Results 1 to 3 of 3
  1. #1
    Emtino is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default How do I print numbers in a line?

    I am taking my first programming class online and don't have a lot of access to the teacher. This week we are supposed to write code which will in essence print a calendar. I am stuck at getting my numbers to print in a horizontal line. Please help.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do I print numbers in a line?

    There are two printing methods that you'll commonly use:

    System.out.println(someString): which prints a String and then a new-line, and
    System.out.print(someString): which prints a String but no new-line. You can use this to print several things on one line.

    Also, consider looking into using System.out.printf(...): which can be useful for printing formatted output. There are decent tutorials easily found on Google which will explain how this works.

  3. #3
    Emtino is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default Re: How do I print numbers in a line?

    Thanks, that helped. I used the System.out.print() and got my output in a horizontal, which is what I wanted. Now I need to limit the number of characters to 7, then go to the next line. I have tried different things and have been able to stop at seven, continue on the next line, but each line after the first printed 8 characters (I did that once, about 2 hours ago, but can't remember how I did it. It had something to do with the '%' symbol). I'm a little frustrated and would appreciate any help.

Similar Threads

  1. How to print palindromic numbers on the console!
    By AlfieSDK in forum New To Java
    Replies: 6
    Last Post: 05-21-2011, 03:24 AM
  2. Replies: 10
    Last Post: 12-20-2010, 01:47 PM
  3. Replies: 6
    Last Post: 12-08-2010, 01:39 AM
  4. print random numbers without repetition
    By princess.blue in forum New To Java
    Replies: 3
    Last Post: 02-04-2010, 10:37 AM
  5. how to multiply numbers in rows and print it next to it
    By racewithferrari in forum New To Java
    Replies: 1
    Last Post: 01-16-2010, 07:24 PM

Posting Permissions

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