Comparable vs. Comparator: Understanding Java Sorting Interfaces
Which statement about the Comparable sorting interface and Comparator comparator is true?
'A. Comparable is a natural sorting interface that identifies relative size between elements, while Comparator is a forced sorting interface.'
'B. Comparable is a forced sorting interface, while Comparator is a natural sorting interface.'
'C. Both Comparable and Comparator must implement the compareTo() method.'
'D. There is no difference between Comparable and Comparator as they both achieve the same sorting functionality.'
Answer: 'A. Comparable is a natural sorting interface that identifies relative size between elements, while Comparator is a forced sorting interface.'
原文地址: https://www.cveoy.top/t/topic/odTK 著作权归作者所有。请勿转载和采集!