Results 1 to 2 of 2

Thread: Format number in java

  1. #1
    DavisMartin is offline Senior Member
    Join Date
    Dec 2009
    Posts
    174
    Rep Power
    3

    Default Format number in java

    I would like to show number in particular format. I want to know How to format number in java?

  2. #2
    PerryCollins is offline Senior Member
    Join Date
    Dec 2009
    Posts
    380
    Rep Power
    3

    Default

    1) If you would like to show numbers that is formatted to particular pattern then use NumberFormat and DecimalFormat class to give format that you desire. Here shown how to do it.

    import java.text.DecimalFormat;
    import java.text.NumberFormat;

    public class DecimalFormat
    {
    public static void main(String[] args)
    {
    NumberFormat F1 = new DecimalFormat("#0.00");
    System.out.println(M);

    System.out.println(F1.format(M));
    }
    }

Similar Threads

  1. Format number in java
    By CoxWatson in forum Programming
    Replies: 1
    Last Post: 06-14-2010, 02:31 PM
  2. Java code palindrome number
    By AllenBrown in forum Programming
    Replies: 2
    Last Post: 06-14-2010, 02:18 PM
  3. C code for given number is Armstrong number or not
    By RussellBarnes in forum Programming
    Replies: 1
    Last Post: 05-29-2010, 12:01 PM
  4. Replies: 2
    Last Post: 05-14-2010, 01:30 PM
  5. Code for sum of odd number and even number separately in c
    By EvansMitchell in forum Programming
    Replies: 2
    Last Post: 05-10-2010, 02:06 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48