Day: March 19, 2020

Comparator List Sorting

Comparator List Sorting In this example showing how to sort objects in the List by using a comparator. Primitive Type List, Wrapper Classes Type List can be sorted by using the Collection.sort(), but Object type List can’t be sorted. To achieve this we can use either Comparator and Comparable.   Comparator A Comparator interface is […]

How to sort primitive data in the list

How to sort primitive data in the list There is a list having primitive data, then how to sort the data in the list. List  – Integer Data Type   ListIntegerSorting.java package com.narayanatutorial.primitive.sorting; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class ListIntegerSorting { public static void main(String args[]) { List<Integer> list = new ArrayList<Integer>(); list.add(123); […]