Skip to content

Convert Integer object to numeric primitive types Example

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

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

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

1) Convert Integer to byte

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

This method returns the value of the Integer object as a byte primitive.

2) Convert Integer to short

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

This method returns the value of the Integer object as a short primitive.

3) Convert Integer to int

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

This method returns the value of the Integer object as an int primitive.

4) Convert Integer to long

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

This method returns the value of the Integer object as a long primitive.

5) Convert Integer to float

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

This method returns the value of the Integer object as a float primitive.

6) Convert Integer to double

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

This method returns the value of the Integer object as a double primitive.

Example

Output

This example is a part of the Java Basic Examples and Java Type conversion Tutorial.

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

About the author

Leave a Reply

Your email address will not be published.