【问题标题】:Cannot implement Comparable无法实现 Comparable
【发布时间】:2017-02-14 09:02:24
【问题描述】:

我正在尝试借助 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() 方法)

【问题讨论】:

  • 问题正是它所说的。 JSONBase 已经实现了 Comparable&lt;JSONBase&gt;。你不能用不同的类型参数重新实现它。
  • 哇。谢谢。我……我只是觉得自己很愚蠢……

标签: java android extend comparable


【解决方案1】:
'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已经实现了,没有再实现的可能。你可以@OverridePass.java中的相应方法

【讨论】:

    猜你喜欢
    • 2014-06-25
    • 2019-07-10
    • 2014-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-06
    • 2016-08-02
    相关资源
    最近更新 更多