Loop Adding BigInteger java -


this question has answer here:

i've got array of bigintegers, , want add them 1 biginteger. i've used method.add(), reason, sum remains 0.

biginteger[] numbers = {                 new biginteger("20849603980134001723930671666823555245252804609722"),                 .                 .                 .                 new biginteger("53503534226472524250874054075591789781264330331690")         };   biginteger sum = new biginteger("0");          for(int = 0; < numbers.length; i++) {             sum.add(numbers[i]);             system.out.println(numbers[i]);             system.out.println(sum);         }         system.out.println(sum); 

thank help!

biginteger immutable - calling sum.add(...) nothing sum returns new biginteger.

so need change code to:

sum = sum.add(numbers[i]); 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -