Java Data Type Tutorial - Java Number.doubleValue()








Syntax

Number.doubleValue() has the following syntax.

public abstract double doubleValue()

Example

In the following code shows how to use Number.doubleValue() method.

/*  w w  w . j  av  a 2s .  com*/


public class Main {

   public static void main(String[] args) {

      // get a number as integer
      Number x = new Integer(123456);

      // get a number as float
      Number y = new Float(9876f);

      // print their value as double
      System.out.println("x as integer :" + x
              + ", x as double:" + x.doubleValue());
      System.out.println("y as float::" + y
              + ", y as double:" + x.doubleValue());

   }
}

The code above generates the following result.