java long to integer
import static java.lang.Math.toIntExact;
long foo = 10L;
int bar = toIntExact(foo);
4.43
7
// auto-unboxing does not go from Long to int directly, so
Integer i = (int) (long) theLong;
Thank you!
7
0
4
1
public class LongToIntExample2{
public static void main(String args[]){
Long l= new Long(10);
int i=l.intValue();
System.out.println(i);
}
}
Thank you!
1
0
0
0
Long l= new Long(i); //first way
Long l2=Long.valueOf(i); //second way
Thank you!
0
0
Are there any code examples left?
New code examples in category Java