xxxxxxxxxx
import static java.lang.Math.toIntExact;
long foo = 10L;
int bar = toIntExact(foo);
xxxxxxxxxx
public class LongToIntExample2{
public static void main(String args[]){
Long l= new Long(10);
int i=l.intValue();
System.out.println(i);
}
}
xxxxxxxxxx
// auto-unboxing does not go from Long to int directly, so
Integer i = (int) (long) theLong;