创建大十进制对象时出错



我使用以下代码,并添加了对大小数的支持和编译器显示为大小数new BigDecimal(nextRandom)创建对象时出错,我该如何克服?

所有其他类型都按预期工作。

public static SwitchInputType<?> switchInput(final String typeName, final String memberName, final int cnt, boolean random) {
...
} else if (typeName.equals("decimal") || (typeName.equals("java.math.BigDecimal"))) {
    BigDecimal nextRandom = RandomizeValues.nextRandom("9");
    return new SwitchInputType<BigDecimal>(new BigDecimal(nextRandom));<-HERE IS THE ERROR
} else if (typeName.equals("boolean")) {
    boolean randomBoolean = RandomizeValues.nextRandom();
    return new SwitchInputType<Boolean>(new Boolean(randomBoolean));
}

错误为:

The constructor BigDecimal(BigDecimal) is undefined

我应该如何克服这一点?

您正在创建

new BigDecimal(nextRandom) 

其中CCD_ 2是CCD_。这毫无意义。

更换线路

return new SwitchInputType<BigDecimal>(new BigDecimal(nextRandom));

带有

return new SwitchInputType<BigDecimal>(nextRandom);

并检查您是否仍然收到相同的错误。

在我看到SwitchInputType 的构造函数之前,不能说任何其他内容

相关内容

最新更新