For example my list contains {4, 6, 6, 7, 7, 8} and I want final result = {6, 6, 7, 7}
One way is to loop through the list and eliminate unique values (4, 8 in this
The following will work with Eclipse Collections:
IntBag bag = IntLists.mutable.with(4, 6, 6, 7, 7, 8).toBag().selectDuplicates();
If you want boxed values instead of primitives, the following will work:
Bag bag = Lists.mutable.with(4, 6, 6, 7, 7, 8).toBag().selectDuplicates();
Note: I am a committer for Eclipse Collections.