Java Double - Java Language Basics

Java examples for Language Basics:double

Description

Java Double

Demo Code


public class Main {
 
  public static void main(String[] args) {
    //create a Double object using one of the below given constructors
   /*from   w  ww.j a  va  2  s.  c o  m*/
    //1. Create an Double object from double primitive type
    double d = 10.10;
    Double dObj1 = new Double(d);
    System.out.println(dObj1);
   
    /*
    2. Create Double object from String. this method can
    throw NumberFormatException if the string doesn't contain number.
    */
    Double dObj3 = new Double("25.34");
    System.out.println(dObj3);    
  }
}

Result


Related Tutorials