无法实现 Comparable
Cannot implement Comparable
我试图借助 Comparable 界面对我的通行证列表进行排序,但我失败得很惨。
public class Pass extends JSONBase implements Comparable<Pass>{
}
此行在 Android Studio 中引发下一个错误:
'java.lang.Comparable' cannot be inherited with different type arguments:
'com.dendrowen.oveasy.model.JSONBase' and 'com.dendrowen.oveasy.model.Pass'
恐怕答案很明显,但我就是看不到! (我当然知道我需要 compareTo()
方法)
'java.lang.Comparable' cannot be inherited with different type arguments:
'com.dendrowen.oveasy.model.JSONBase' and 'com.dendrowen.oveasy.model.Pass
这是一个详细描述问题的错误。它说:
The Interface 'java.lang.Comparable' cannot be inherited with different type arguments
You're trying to inherite it with type JSONBase and Pass.
说明JSONBase已经实现了,不可能再实现了。您可以@Override
Pass.java
中的适当方法
我试图借助 Comparable 界面对我的通行证列表进行排序,但我失败得很惨。
public class Pass extends JSONBase implements Comparable<Pass>{
}
此行在 Android Studio 中引发下一个错误:
'java.lang.Comparable' cannot be inherited with different type arguments:
'com.dendrowen.oveasy.model.JSONBase' and 'com.dendrowen.oveasy.model.Pass'
恐怕答案很明显,但我就是看不到! (我当然知道我需要 compareTo()
方法)
'java.lang.Comparable' cannot be inherited with different type arguments:
'com.dendrowen.oveasy.model.JSONBase' and 'com.dendrowen.oveasy.model.Pass
这是一个详细描述问题的错误。它说:
The Interface 'java.lang.Comparable' cannot be inherited with different type arguments
You're trying to inherite it with type JSONBase and Pass.
说明JSONBase已经实现了,不可能再实现了。您可以@Override
Pass.java