0

I would just like to know what the highest number is that I can put in place of x:

int[] tally = new int[x];

Thank you.

FΣynman
  • 67
  • 1
  • 7

2 Answers2

0

You could theoretically put in Integer.MAX_VALUE since that is the highest integer value you can have. But it depends on how much RAM you have, for example if you have 2 billion numbers you would need at least 32 bit * 2 billion = 8 GB of RAM and that is just for the array itself. So you could pick a number like a million and that should do for you.

applecrusher
  • 5,508
  • 5
  • 39
  • 89
0

A constant holding the maximum value an int can have, (2 in power of 31)-1, but that would be horrendously huge array that would use huge amount of memory. It's hard to think of a use case where you'd need such a thing. If you are thinking about creating such a monstrosity - most likely something is wrong with your design.

Michael Gantman
  • 7,315
  • 2
  • 19
  • 36