Java 如何转换 Long 为 Integer

可以使用下面的方法进行转换:

Integer i = theLong != null ? theLong.intValue() : null;

如果你不需要担心 NULL 对象的话。

// auto-unboxing does not go from Long to int directly, so Integer i = (int) (long) theLong;