double into a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oll3i
    Contributor
    • Mar 2007
    • 679

    double into a string

    how to convert a double into a string
  • olakara
    New Member
    • Nov 2006
    • 18

    #2
    Hi,
    Here is one way to convert to double to string..
    Code:
    double a= 12.20;
    Double a1 = new Double(a);
    String x = a1.toString();
    You can always convert the basic type to its class.. like int to Integer, double to Double and then convert it into String using the toString() method.
    Another way to convert is concatenate the int/double with a string. for example
    Code:
       String a = " " + 12.20;
    But remember to trim the space using the trim() method.
    Hope this will help you out
    Thanks and Regards,
    -- Abdel Olakara

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Code:
       double x = 12.0; 
      String s = "" + x;

      Comment

      • oll3i
        Contributor
        • Mar 2007
        • 679

        #4
        thanks a lot

        Comment

        Working...