making an array of bigInteger of size biginteger in java

流过昼夜 提交于 2020-01-03 05:34:08

问题


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; 


来源:https://stackoverflow.com/questions/15038754/making-an-array-of-biginteger-of-size-biginteger-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!