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