Java Basic Examples

Convert Float object to numeric primitive types Example

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

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

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

1) Convert Float to byte

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

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

2) Convert Float to short

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

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

3) Convert Float to int

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

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

4) Convert Float to long

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

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

5) Convert Float to float

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

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

6) Convert Float to double

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

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