Converting Integer to Long

前端 未结 16 2036
轮回少年
轮回少年 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:12

    Converting Integer to Long Very Simple and many ways to converting that
    Example 1

     new Long(your_integer);
    

    Example 2

    Long.valueOf(your_integer); 
    

    Example 3

    Long a = 12345L;
    

    Example 4
    If you already have the int typed as an Integer you can do this:

    Integer y = 12;
    long x = y.longValue();
    

提交回复
热议问题