how to convert long to int in java code example
Example 1: convert string to int java
String myString = "1234";
int foo = Integer.parseInt(myString);
Example 2: long to int java 8
import static java.lang.Math.toIntExact;
long foo = 10L;
int bar = toIntExact(foo);
Example 3: java long to int
public class LongToIntExample2{
public static void main(String args[]){
Long l= new Long(10);
int i=l.intValue();
System.out.println(i);
}
}
Example 4: java long to integer
// auto-unboxing does not go from Long to int directly, so
Integer i = (int) (long) theLong;