Skip to Content

Convert Double object to String object

  1. /*
  2.   Convert Double object to String object
  3.   This example shows how a Double object can be converted into a String object.
  4. */
  5.  
  6. public class JavaDoubleToStringExample {
  7.  
  8.   public static void main(String[] args) {
  9.     Double dObj = new Double(10.25);
  10.    
  11.     //use toString method of Double class to convert Double into String.
  12.     String str = dObj.toString();
  13.     System.out.println("Double converted to String as " + str);
  14.   }
  15. }
  16.  
  17. /*
  18. Output of the program would be
  19. Double converted to String as 10.25
  20. */

Advertisement: