casting to int java code example
Example 1: convert string to int java
String myString = "1234";
int foo = Integer.parseInt(myString);
Example 2: java string to int
int result = Integer.parseInt("500");
System.out.println(result)
Example 3: how to change double to int in java
class Scratch{
public static void main(String[] args){
double decimal = 5.7;
System.out.println( (int) decimal );
System.out.println( Math.round(decimal * 10) / (double) 10);
System.out.println( decimal % 1);
System.out.println( Integer.parseInt( String.valueOf(decimal).substring(0, String.valueOf(decimal).indexOf("."))));
}
}