Return double value as byte, double, float, int, long, short

byte byteValue()
Returns a byte (by casting to a byte).
double doubleValue()
Returns the double value of this Double object.
float floatValue()
Returns the float value of this Double object.
int intValue()
Returns the value of this Double as an int (by casting to type int).
long longValue()
Returns the value of this Double as a long (by casting to type long).
short shortValue()
Returns the value of this Double as a short (by casting to a short).

public class Main {
  public static void main(String[] args) {
    Double doubleObject = new Double("10.01");
    byte b = doubleObject.byteValue();
    System.out.println("byte:"+b);

    short s = doubleObject.shortValue();
    System.out.println("short:"+s);

    int i = doubleObject.intValue();
    System.out.println("int:"+i);

    float f = doubleObject.floatValue();
    System.out.println("float"+f);

    double d = doubleObject.doubleValue();
    System.out.println("double:"+d);

    long l = doubleObject.longValue();
    System.out.println("long:"+l);
  }
}

The output:


byte:10
short:10
int:10
float10.01
double:10.01
long:10
Home 
  Java Book 
    Essential Classes  

Double:
  1. Double class
  2. Constants in Double class
  3. Double class Constructor
  4. Return double value as byte, double, float, int, long, short
  5. Compare two double values
  6. Is a double value an infinite large value, or it is not a number.
  7. Convert string value to double
  8. Convert double value from string
  9. Get the hexadecimal string representation
  10. Bit oriented calculation for double type