나는 일반 datacontainer를 구축했으며 이제는 해당 유형에 따라 데이터를 조작하려고합니다. 그러나, 호환되지 않는 유형의 경고가 나타납니다. 내가 도대체 뭘 잘못하고있는 겁니까?자바 제네릭 변환
Type _Value;
public void set(Type t) throws Exception {
if (_Value instanceof Integer
&& t instanceof Integer) {
_Value = (((Integer) t
- _MinValue + getRange())
% getRange()) + _MinValue;
}
else if (_Value instanceof Boolean
&& t instanceof Boolean) {
_Value = t;
}
else throw new Exception("Invalid type");
}
클래스가 정의되는 방법과 인스턴스가 생성되는 방법을 보여줍니다. –