1

I want to create a matrix of BigInteger whose dimension is a BigInteger too, but this create a error and I don't know why

BigInteger[][] matA;
BigInteger n;
System.out.println("Ingrese N: ");
n = sc.nextBigInteger();
matA = new BigInteger[n][n];

This is the error of java:

incompatible types: BigInteger cannot be converted to int

Raul Juliao
  • 55
  • 1
  • 6
  • 3
    The max size of an array is 2^32-1 so it's not possible – Keatinge Aug 10 '17 at 03:51
  • 5
    Arrays are indexed by `int`. Not `BigInteger`. And arrays (per the Java specification) have a **fixed** `length` field (which is also of type `int`). If this is *intended* to be sparse, you could probably write something based on a [`Map, BigInteger>`](https://stackoverflow.com/a/6045145/2970947). – Elliott Frisch Aug 10 '17 at 03:52
  • 2
    this is because the array index expects an int argument, not a BigInteger – Saransh Kejriwal Aug 10 '17 at 03:52

0 Answers0