Use the class BigInteger, it can handle arbitrary long numbers (that is, as big as computer memory allows).
Link: http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html
Domanda
How to handle 1000 digit number? Anyone can explain it?
My code;
Long sum = 1L;
...
if (String.valueOf(sum).length() == 1000) {
...
}
But not working, anyone can explain it?
Soluzione
Use the class BigInteger, it can handle arbitrary long numbers (that is, as big as computer memory allows).
Link: http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html
Altri suggerimenti
Use a BigInteger
instead. See the documentation here.