Search code examples
javaandroidextendcomparable

Cannot implement Comparable


I'm trying to sort my list of passes with some help of the Comparable interface but I fail horribly.

public class Pass extends JSONBase implements Comparable<Pass>{

}

This line raises the next error in Android Studio:

'java.lang.Comparable' cannot be inherited with different type arguments: 
'com.dendrowen.oveasy.model.JSONBase' and 'com.dendrowen.oveasy.model.Pass'

I'm afraid the answer is obvious but I just don't see it! (I of course do know I need the compareTo() method)


Solution

  • 'java.lang.Comparable' cannot be inherited with different type arguments:
    'com.dendrowen.oveasy.model.JSONBase' and 'com.dendrowen.oveasy.model.Pass
    

    It's an error which describes the problem in detail. It says:

    The Interface 'java.lang.Comparable' cannot be inherited with different type arguments
    You're trying to inherite it with type JSONBase and Pass.
    

    It means that JSONBase already implements it and there is no possibility to implement it again. You can @Override the appropriate method in Pass.java