Convert String Float to Int in Java

This program is to convert a string float value to an Integer

Source code :

public class TypeConversion {
 
  public static void main(String[] args) {

    String floatString = "75.000";
   
    Float floatValue = Float.parseFloat(floatString);
    
    Integer intValue = (int) floatValue; //This will be an Integer

    System.out.println(intValue);
   
  }
}

Output :

75

Output :


                

Comments :