Java – sort a list of non comparable elements
•
Java
Today, I was asked this interview question:
I know I need to make the person class implement comparable and then override CompareTo, but what happens if I don't?
Solution
It does not compile: collections The 1 - parameter version of sort requires a comparable list Specifically, the list < T > where t implements comparable
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码