how to convert long to int java code example
Example 1: long to int java 8
import static java.lang.Math.toIntExact;
long foo = 10L;
int bar = toIntExact(foo);
Example 2: 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 3: int to long java
Long l= new Long(i); //first way
Long l2=Long.valueOf(i); //second way