Log in

View Full Version : Formatting error


javeriaz
Jun 30, 2008, 04:39 AM
I'm new with java.. following the book "teach yourself java in 21 days"

I tried to print
System.out.format("%,d%n", total[0]);
And it printed 5a000a000 instead of 5,000,000

Why??

jstrike
Jul 7, 2008, 06:55 PM
i'm new with java.. following the book "teach yourself java in 21 days"

i tried to print
System.out.format("%,d%n", total[0]);
and it printed 5a000a000 instead of 5,000,000

why???
The statement is correct and when I ran it on my machine I got the correct result.
What OS are you running this on?
What are you using to compile?
I would recommend you place: System.out.println(total[0]); on the line right before the format just to make sure the value in total[0] is what you expect.