The intValue() method in Float Class is a built in method in Java that returns the value specified by the calling object as int after type casting.
Syntax:
public int intValue()
Parameters: The function accepts no parameter.
Return Value: It return the value of FloatObject as int.
Below programs illustrate intValue() method in Java:
Program 1:
// Java code to demonstrate // Float intValue() 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); // intValue of the Float Object int output = b.intValue(); // printing the output System.out.println("Int value of " + b + " is : " + output); } } |
Int value of 17.47 is : 17
Program 2:
// Java code to demonstrate // Float intValue() method // Not a number class GFG { public static void main(String[] args) { // Float value Float a = Float.NaN; // wrapping the Float value // in the wrapper class Float Float b = new Float(a); // intValue of the Float Object int output = b.intValue(); // printing the output System.out.println("Int value of " + b + " is : " + output); } } |
Int value of NaN is : 0
Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#intValue()
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- LongAdder intValue() method in Java with Examples
- DoubleAdder intValue() method in Java with Examples
- AtomicInteger intValue() method in Java with examples
- LongAccumulator intValue() method in Java with Examples
- AtomicLong intValue() method in Java with examples
- Number.intValue() method in java with examples
- DoubleAccumulator intValue() method in Java with Examples
- Level intValue() method in Java with Examples
- Double intValue() method in Java with examples
- Byte intValue() 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 isInfinite() method in Java with examples
- Float doubleValue() method in Java with examples
- Float compareTo() method in Java with examples
- Float hashCode() method in Java with examples
- Float shortValue() method in Java with examples
- Float isNaN() method in Java with examples
- Float floatToRawIntBits() method in Java with examples
- Float parseFloat() 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.

