標準入力からいくつかの非常に大きな数値を読み取って、それらを合計しようとしています。
ただし、BigIntegerに追加するには、次を使用する必要がありますBigInteger.valueOf(long);。
private BigInteger sum = BigInteger.valueOf(0);
private void sum(String newNumber) {
    // BigInteger is immutable, reassign the variable:
    sum = sum.add(BigInteger.valueOf(Long.parseLong(newNumber)));
}
これは問題なく機能しますが、をBigInteger.valueOf()とるだけなので、の最大値(9223372036854775807)longより大きい数値を追加することはできませんlong。
9223372036854775808以上を追加しようとすると、NumberFormatExceptionが発生します(これは完全に予想されます)。
のようなものはありBigInteger.parseBigInteger(String)ますか?