Object sequential searching using compareTo()
I have this simple method to search for an object that uses
Comparable interface. But I'm wondering, why does my parameter should use extends instead of implements? Doesn't this break the law where an object can only extend ONE class, but is able to implement multiple interfaces? So why doesn't implements work here?
12 Replies
⌛ This post has been reserved for your question.
Hey @circle! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
why isn't it:
<T Comparable<T>>
Another method I can use is using raw implementation of casting the to be compared object to Comparable interface. But this still means it was casted to a class(?) instead of the interface.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.
Sorry for the late reply, does that mean T as the parameter data type is already an interface?
TIA
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.
So T can be extended into any interface? Even though interface is not a class?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
T extends InterfaceB & InterfaceC is valid syntaxUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.