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: Format Java output

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Format Java output

    I am in my first Java class. My first assignment requires me to offset my output by 25 spaces from the beginning of the line and I have no idea how to do this. I have found System.out.printf and Formatter but do not know if these will do what I need. I have read about both of these but am having trouble figuring them out. Can somebody please help me out?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Format Java output

    Did you read the API doc for the printf method? It has a link to Format String syntax that explains how to use it.
    Also do a Search on the forum for printf to find some code examples.
    Then write some sample code to test it out. Try it many different ways to see what the effects of changing this part and that part do to the output.

  3. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Format Java output

    Thank you.

Similar Threads

  1. The java-output doesn't give the right result?
    By pinotje in forum What's Wrong With My Code?
    Replies: 8
    Last Post: May 31st, 2011, 01:00 PM
  2. Help needed for "java.io.IOException: Not in GZIP format"
    By goldest in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: August 10th, 2010, 03:05 AM
  3. [SOLVED] java me how to: input - math operation - output
    By Lifer in forum Java ME (Mobile Edition)
    Replies: 3
    Last Post: April 7th, 2010, 05:36 PM
  4. Output String Handling in Java
    By merry in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 21st, 2010, 09:59 PM
  5. Format some text with Java
    By vampire in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 18th, 2010, 11:30 AM