Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Float.intValue() method is used to return the value of this Float as an int after a narrowing primitive conversion.

Syntax

public int intValue()

Parameters

No parameter is required.

Return Value

Returns the float value represented by this object converted to type int.

Exception

NA.

Example:

In the below example, the java.lang.Float.intValue() method is used to return a Float object after conversion to type int.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating Float objects
    Float val1 = new Float("25.2f");
    Float val2 = new Float("-25.2");

    //printing intValue of the Float objects
    System.out.println("intValue of the val1 is: " + val1.intValue()); 
    System.out.println("intValue of the val2 is: " + val2.intValue());   
  }
}

The output of the above code will be:

intValue of the val1 is: 25
intValue of the val2 is: -25

❮ Java.lang - Float