<Length>
我使用 javax.measure 编写了一些代码,当我从我们的存储库中提取更新的代码时,每当我尝试从 javax.measure中使用时,我都会收到一个 Bound Mismatch 错误。
编辑确切的错误是:
绑定不匹配:类型 Length 不是该类型的有界参数
<Q extends Quantity>
的有效替代品BaseUnit<Q>
我将代码移动到一个干净的工作区,一切都很好,但由于某种原因,在我的主工作区它不起作用。
为什么会这样?我正在使用eclipse,有问题的代码如下
import javax.measure.Measure;
import javax.measure.quantity.Length;
import javax.measure.unit.BaseUnit;
public class MyUnit{
BaseUnit<Length> unitType;
Measure<Length> unitValue;
public MyUnit(double value, String abbreviation) {
this.unitType = new BaseUnit<Length>(abbreviation);
this.unitValue = Measure.valueOf(value, unitType);
}
public double getValue() {
return (double)this.unitValue.getValue();
}
public String getUnit() {
return this.unitType.getSymbol();
}
}