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.

Begginer Question please help ASAP! (Easy to Answer)

Hi, first of all i appologise right upfront for not reading your posting rules yet, but i'm in a huge rush atm finishing an assigmnent due tommorow morning and i need a bit of help with a simple printf statement.

My question is very simple, when using System.out.printf(); statement you can use it to show result from a double. for example i'm showing a value from variable so i say %6.2f meaning 6 digits long and 2 numbers after decimal. So if my number is 5 digits long it will print 5 digits and a blank space at the end to count as the 6th character in the number. My question is if there are 5 numbers, how do i tell it to print the space before the 5 numbers so instead of looking like this:

number = 54.04 ;

to look like this

number = 54.04;

I tried my very best to explain and in desparate need of help ^^ thank you.