Java Basic Examples

Convert Short object to numeric primitive types Example

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

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

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

1) Convert Short to byte

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

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

2) Convert Short to short

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

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

3) Convert Short to int

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

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

4) Convert Short to long

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

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

5) Convert Short to float

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

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

6) Convert Short to double

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

This method returns the value of the Short 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: