View RSS Feed

Advanced Java

Advanced Java programming.

  1. Using Collections.sort and Comparator in Java

    by , 02-18-2012 at 05:05 PM
    Sorting a collection in Java is easy, just use Collections.sort(Collection) to sort your values. For example:
    Collection sorting is easier in Java. To sort the values, use Collection.sort (Collection). E.g

    Java Code: This is the code to explain collection sort and comparator methods
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;
    public class SimpleSort {
        public static void main(String[] args) {
            List list = new ArrayList();
            list.add(5);
    ...