2013-02-10 1 views
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 

어떻게이를 극복해야합니까?

+2

의 생성자를 볼 때까지

은 ** 최소로 아래로 예제 코드를 잘라하시기 바랍니다 아무것도 말할 수 없다 ** 컴파일러 오류를 입증해야. –

+1

와 무엇이 오류입니까? – ogzd

+0

다른 BigDecimal 객체로부터 BigDecimal 객체를 작성하는 이유는 무엇입니까? 중복 된 것 같습니다. –

답변

6
당신은 nextRandomBigDecimal입니다

new BigDecimal(nextRandom) 

를 만드는

. 그건 말이 안돼.

return new SwitchInputType<BigDecimal>(nextRandom); 

와 라인

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

를 교체 그리고 당신은 여전히 ​​같은 오류가 있는지 확인합니다. 내가 SwitchInputType