How do I convert a String to a BigInteger?

前端 未结 6 1426
自闭症患者
自闭症患者 2020-11-30 08:09

I\'m trying to read some really big numbers from standard input and add them together.

However, to add to BigInteger, I need to use BigInteger.valueOf(long);

6条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 08:46

    For a loop where you want to convert an array of strings to an array of bigIntegers do this:

    String[] unsorted = new String[n]; //array of Strings
    BigInteger[] series = new BigInteger[n]; //array of BigIntegers
    
    for(int i=0; i

提交回复
热议问题