问题描述
我被分配了以下问题:编写一个通用的WeightedElement
到目前为止,我已经使类和实现具有可比性,但是在为W创建compareTo()方法时遇到问题。
public class WeightedElement<E,W extends Comparable<W>> {
public E element;
public W weight;
public WeightedElement() {
element = this.element;
weight = this.weight;
}
public int compareTo(W data) {
if (this.weight == data.weight) {
return 0;
} else if (this.weight < data.weight) {
return 1;
} else {
return 1;
}
}
}
我遇到一个问题,当我比较权重时,找不到数据的权重。另外,我还必须创建其他任何方法来适当地实现一个可比较其中一个变量的类吗?谢谢您的帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)