Merging two sorted collections

Apache Common Collections API provide a facility to merge two sorted collections. This post will show how to use it with an example Main Code 1 import java.util.ArrayList; 2 import java.util.List; 3 4 import org.apache.commons.collections4.CollectionUtils; 5 6 public class Example3 { 7 public static void main(String[] args) { 8 List list1 = new ArrayList(); 9…… Continue reading Merging two sorted collections

Bag Collection

A bag or multiset is a collection that allow duplicate items. It also keeps count of how many duplicate items are present. Apache Collections framework provide an implementation of Bag collection. Below is an example of it. Bag example 1 import org.apache.commons.collections4.Bag; 2 import org.apache.commons.collections4.bag.HashBag; 3 4 public class Example1 { 5 public static void…… Continue reading Bag Collection