How do I sort items of an ArrayList?
Category: java.util, viewed: 33010 time(s).
This example shows you how we can sort items of an ArrayList using the Collections.sort() methods. Beside accepting the list object to be sorted we can also pass a Comparator implementation to define the sorting behavior.
The code will output:
[black, blue, cyan, green, red, white, yellow] [yellow, white, red, green, cyan, blue, black]
Can't find what you are looking for? Join our FORUMS and ask some questions!
Download Hundreds of Complimentary Industry Resources
Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more;
all available at no cost to you. With more than 600 complimentary offers, you'll find
plenty of titles to suit your professional interests and needs.
Click Here and Sign up today!
