Skip to Content

Convert java double to Double object Example

  1. /*
  2.   Convert double to Double object Example
  3.   This example shows how a double primitive value can be converted to a Double object
  4. */
  5.  
  6. public class JavadoubleToDoubleExample {
  7.  
  8.   public static void main(String[] args) {
  9.     double d = 10.56;
  10.    
  11.     /*
  12.     Use Double constructor to convert double primitive type to a Double object.
  13.     */
  14.    
  15.     Double dObj = new Double(d);
  16.     System.out.println(dObj);
  17.  
  18.   }
  19. }
  20.  
  21. /*
  22. Output of the program would be
  23. 10.56
  24. */