A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
Usage of Comparable for sorting
Joined: May 03, 2008
Jul 26, 2008 07:33:00
can we use Comparable interface for sorting while using Arrays.sort() method
Joined: Apr 27, 2008
Jul 26, 2008 08:03:00
The comparable interface is used implicitely: If your class, say A, implements Comparable and you sort an array of type A, its compareTo method is used for sorting.
Moreover, you can define a comparator class that implements the Comparator interface and use it explicitely in the sort method.
SCJP 5 (98%) - SCBCD 5 (98%)
I agree. Here's the link:
subject: Usage of Comparable for sorting
Comparable And Comparator usage in real time
collections: why duplicates arent getting eradicated?
why arrayLIst does not sort the elements i add
doubt in treeset...
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015