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
Java Book
Essential Classes
Double:
- Double class
- Constants in Double class
- Double class Constructor
- Return double value as byte, double, float, int, long, short
- Compare two double values
- Is a double value an infinite large value, or it is not a number.
- Convert string value to double
- Convert double value from string
- Get the hexadecimal string representation
- Bit oriented calculation for double type