Java Double create

Introduction

The following example creates two Double objects:

  • one by using a double value
  • one by passing a string that can be parsed as a double:
public class Main {
  public static void main(String args[]) {
    Double d1 = new Double(3.14159);
    Double d2 = new Double("314159E-5");

    System.out.println(d1 + " = " + d2 + " -> " + d1.equals(d2));
  }/*  w  ww.  ja  va2s . c  o  m*/
}



PreviousNext

Related