In Java, how do I store numbers in an array, I mean really long numbers like up to 1 trillion so I can access them and print out in words what they are?
1 trillion isn't that big - just use a long
, which can store a number as large as 9223372036854775807 (more than a quintillion):
long[] numbers = new long[1000];
To store arbitrarily large numbers, use BigInteger
, but they can be a hassle:
BigInteger[] numbers = new BigInteger[1000];
You need BigInteger if its really that large. For trillion. Long is enough
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With