Please understand that Long
and Integer
are object classes, while long
and int
are primitive data types. You can freely cast between the latter (with possible loss of high-order bits), but you must do an actual conversion between the former.
Integer newInt = new Integer(oldLong.intValue());