Converting Integer to Long

前端 未结 16 2241
轮回少年
轮回少年 2020-12-07 13:47

I need to get the value of a field using reflection. It so happens that I am not always sure what the datatype of the field is. For that, and to avoid some code duplication

16条回答
  •  孤街浪徒
    2020-12-07 14:15

    If you know that the Integer is not NULL, you can simply do this:

    Integer intVal = 1;
    Long longVal = (long) (int) intVal
    

提交回复
热议问题