Collections

  • Collections is a special static class under java.util that contains various static methods on collection operations. Provides a series of static methods for searching, sorting, thread-safe operations on various collections.

    public static void main(String[] args) {
        List list = new ArrayList();
        list.add(17);
        list.add(11);
        list.add(65);
        list.add(36);
    
        Collections.sort(list);
    
        System.out.println(list);//[11, 17, 36, 65]
    }

Arrays

  • Arrays is a special static class under java.util that contains Arrays of operations and provides static methods such as search, sort, copy, and so on.

    public static void main(String[] args) {
        int[] array = new int[]{11, 4, 23, 16, 3, 1, 4};
    
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));//[1, 3, 4, 4, 11, 16, 23]
    }