集册 Java实例教程 Java Double

Java Double

欢马劈雪     最近更新时间:2020-01-02 10:19:05

463
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
Java Double


public class Main {

 

  public static void main(String[] args) {
  /*
  n o w j a   v  a . c o m - 时  代  Java
  */

    //create a Double object using one of the below given constructors

   

    //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);    

  }

}/**N o w J a v a . c o m - 时代Java**/