Convert Long into Integer

后端 未结 14 2121
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 07:48

How to convert a Long value into an Integer value in Java?

14条回答
  •  温柔的废话
    2020-12-07 07:55

    Assuming not null longVal

    Integer intVal = ((Number)longVal).intValue();
    

    It works for example y you get an Object that can be an Integer or a Long. I know that is ugly, but it happens...

提交回复
热议问题