1
我使用下面的代碼,我添加了對大十進制的支持和編譯器顯示 錯誤創建對象爲大小數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
我應該怎樣解決呢?
構造請把你的示例代碼下降到最低** **證明編譯器錯誤需要。 – 2013-02-10 16:33:17
和什麼是錯誤? – ogzd 2013-02-10 16:34:01
爲什麼要創建另一個BigDecimal對象的BigDecimal對象?似乎多餘 – 2013-02-10 16:35:00