Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Double Wrapper Class

Posted By: Max Howard     Category: Java     Views: 9228

This article explains about Double wrapper class in java.

Double wrapper class is used to wrap primitive data type double value in an object. 

Examples of Double Wrapper Class

Example 1 : Convert double to Double object 

public class doubleToDouble
{
 
  public static void main(String[] args) 
  {
    double d = 1.2;
 
    Double dObj = new Double(d);
    System.out.println(dObj);
  }
}
 

Output 
1.2

This example shows how a double data type value can be converted to a Double object.

Example 2 : Convert Double object to String object

public class DoubleToString
{
 
  public static void main(String[] args) 
  {
    Double dObj = new Double(1.2);
 
    String str = dObj.toString();
    System.out.println("Double converted to String as " + str);
  }
}
 

Output
Double converted to String as 1.2

This example shows how a Double object can be converted into a String object.

  
Share: 

 
 

Didn't find what you were looking for? Find more on Double Wrapper Class Or get search suggestion and latest updates.

Max Howard
Max Howard author of Double Wrapper Class is from Houston, United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!