0

I am writing a program and stuck with below issue of BigInteger.

BigInteger noOfCombinationForWordsToBeSearchedBig = factorial(noOfWordsToBeSearched);
String[][] combinationForWordsToBeSearched = new String[ noOfCombinationForWordsToBeSearchedBig.longValue()][noOfWordsToBeSearched];

I want to initialize the String[][] array with value of noOfCombinationForWordsToBeSearchedBig .

For examaple, i am finding factorial of 17 which is big integer.

Please advise.

Rohit Jain
  • 209,639
  • 45
  • 409
  • 525
  • 1
    Even if Java allowed you to initialize an array this big, do you have enough ram to store 17!=355687428096000 pointers to String? Assuming each pointer is 8 byte, you'd need 2845TB of RAM. – Giulio Franco Aug 24 '13 at 13:56

1 Answers1

4

Array index can not be more than Integer.MAX_VALUE in Java. In fact its much less than Integer.MAX_VALUE. So actually you can not put BigInteger as the size parameter, while creating an array.

For details see here.

Community
  • 1
  • 1
Sazzadur Rahaman
  • 6,938
  • 1
  • 30
  • 52