Converting from Integer, to BigInteger

前端 未结 2 1513
猫巷女王i
猫巷女王i 2020-12-07 21:30

I was wondering if there was any way to convert a variable of type Integer, to BigInteger. I tried typecasting the Integer variable, but i get an error that says inconvertib

2条回答
  •  孤城傲影
    2020-12-07 21:57

    The method you want is BigInteger#valueOf(long val).

    E.g.,

    BigInteger bi = BigInteger.valueOf(myInteger.intValue());
    

    Making a String first is unnecessary and undesired.

提交回复
热议问题