Java - Convert long to int

long l = 1;
int i = (int) l;



To do it safely:

public static int convertLongToInt(long l) {
    if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) {
        throw new IllegalArgumentException
            ("Invalid value for: " + l);
    }
    return (int) l;
}