Float floatValue() in Java with examples
The floatToRawIntBits() method in Float Class is a built-in function in java that retursn the value specified by the calling object as float after type casting.
Syntax:
public float floatValue()
Return Value: It return the value of FloatObject as float.
Below programs illustrate floatValue() method in Java:
Program 1:
// Java code to demonstrate // Float floatValue() method class GFG { public static void main(String[] args) { // Float value Float a = 17.47f; // wrapping the Float value // in the wrapper class Float Float b = new Float(a); // floatValue of the Float Object float output = b.floatValue(); // prfloating the output System.out.println("Float value of " + b + " is : " + output); } } |
chevron_right
filter_none
Output:
Float value of 17.47 is : 17.47
Program 2:
// Java code to demonstrate // Float floatValue() method class GFG { public static void main(String[] args) { String value = "54.1"; // wrapping the Float value // in the wrapper class Float Float b = new Float(value); // floatValue of the Float Object float output = b.floatValue(); // prfloating the output System.out.println("Float value of " + b + " is : " + output); } } |
chevron_right
filter_none
Output:
Float value of 54.1 is : 54.1
Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#floatValue()
Recommended Posts:
- Double floatValue() in Java with Examples
- LongAccumulator floatValue() method in Java with Examples
- Number.floatValue() method in java with examples
- AtomicInteger floatValue() method in Java with examples
- AtomicLong floatValue() method in Java with examples
- DoubleAccumulator floatValue() method in Java with Examples
- Byte floatValue() method in Java with examples
- LongAdder floatValue() method in Java with Examples
- DoubleAdder floatValue() method in Java with Examples
- BigDecimal floatValue() Method in Java with Examples
- Java Guava | Floats.indexOf(float[] array, float[] target) method with Examples
- Java Guava | Floats.indexOf(float[] array, float target) method with Examples
- Float longValue() in Java with Examples
- Float isNaN() method in Java with examples
- Float isInfinite() method in Java with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



