I am creating a class ExtendBigInt
that extends the BigInteger class and needs to able to set the default value to 0. However, since BigInteger cannot be edited, how do I create a no parameter constructor in the child class? When I try to create a constructor of the child class with no parameter, it throws this error Implicit super constructor BigInteger() is undefined. Must explicitly invoke another constructor
import java.math.BigInteger;
public class ExtendBigInt extends BigInteger{
public ExtendBigInt() {
}
public static void main(String[] args) {
//BigInteger one = new BigInteger("0");
//BigInteger two = new BigInteger("1111111111111111111111");
//BigInteger result = one.subtract(two);
//System.out.println(one); // -1111111111110987654322
//double down = result.doubleValue(); // returns a double
//System.out.println(down); // -1.1111111111109876E21
//System.out.println(one.toString()); // 123456789
//System.out.println(result.subtract(two)); // -2222222222222098765433
//System.out.println(one.multiply(two)); // 137174209999999999999986282579
//System.out.println(result.multiply(result).multiply(result).multiply(result));
// 1524157902758048400486511315461168814591948287890638869506006559674928884826743139856
//System.out.println(BigInteger.ONE); // Commonly used BigInteger("1")
}
}
Just do
public ExtendBigInt() {
super("0");
}
There isn't an empty constructor in BigInteger
, thus you get that error