Java Basic Examples

Convert Double object to numeric primitive types Example

This example shows how to convert Double object to numeric primitive types like Double object to byte, Double object to short, Double object to int, Double object to long, Double object to float and Double object to double.

How to convert Double object to numeric primitive types in Java?

Use xxxValue method of Double wrapper class to convert Double object to primitive numeric types where xxx is the primitive type you want to convert to as given below.

1) Convert Double to byte

Use byteValue method of Double wrapper class to convert from Double to byte primitive value.

This method returns the value of the Double object as byte primitive.

2) Convert Double to short

Use shortValue method of Double wrapper class to convert from Double to short primitive value.

This method returns the value of the Double object as short primitive.

3) Convert Double to int

Use intValue method of Double wrapper class to convert from Double to int primitive value.

This method returns the value of the Double object as int primitive.

4) Convert Double to long

Use longValue method of Double wrapper class to convert from Double to long primitive value.

This method returns the value of the Double object as long primitive.

5) Convert Double to float

Use floatValue method of Double wrapper class to convert from Double to float primitive value.

This method returns the value of the Double object as float primitive.

6) Convert Double to double

Use doubleValue method of Double wrapper class to convert from Double to double primitive value.

This method returns the value of the Double object as double primitive.

Example

Output

Please let us know your views in the comments section below.

 

Join 1000+ fellow learners! Enter your email address below: