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  a va  2 s.  c o  m*/


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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable