Converting from int type to long type is upconverting, and you can directly perform implicit conversion, but converting from long type to int type is downconverting, and data overflow may occur:
The following conversion methods are mainly for reference:
1. Forced type conversion
long ll = 300000; int ii = (int)ll;
2. Call the intValue() method
long ll = 300000; int ii= new Long(ll).intValue();
3. First convert long into a string String, and then convert the line into an Integer
long ll = 300000; int ii = Integer.parseInt(String.valueOf(ll));
These three methods are simpler and clear.