making an array of bigInteger of size biginteger i

2019-06-14 05:32发布

问题:

i am trying to make an array of biginteger of size biginteger.

public class Polynomial4   
{  
private BigInteger[] coef;      
private BigInteger deg;   
public Polynomial4(BigInteger a,BigInteger b)   
{  
coef =  new BigInteger[b+1];// here its giving the error   
coef[b] = a; // here also its showing error *  ///required int found Biginteger  

}    

}    

please help me....thanks in advance....

回答1:

BigInteger has an intValue method. which converts BigInteger into an int primitive.arrays expect an int as its size while BigInteger is an object.

    coef =  new BigInteger[b.intValue()+1];
       coef[b.intValue()] = a;