Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Formatting error (https://www.askmehelpdesk.com/showthread.php?t=232268)

  • Jun 30, 2008, 04:39 AM
    javeriaz
    Formatting error
    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??
  • Jul 7, 2008, 06:55 PM
    jstrike
    Quote:

    Originally Posted by javeriaz
    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.

  • All times are GMT -7. The time now is 03:55 AM.