Sep 13, 2018

How to remove duplicate objects from ArrayList in Java?

Yes, there is a collection called Set which is used for storing unique elements but there are situations when you need to remove duplicates from ArrayList before processing. Simplest way to to get rid of duplicates is copying elements from ArrayList to LinkedHashSet, clear the array and then again copy object from LinkedHashSet to ArrayList. Why LinkedHashSet? Why not simple HashSet, because List are ordered collection and if you use HashSet you may lose the original order of element as it doesn't provide any guarantee, but LinkedHashSet does. It keeps elements in the order they are inserted.

QuickBooks Self-Employed

Bigger tax refunds. Better organization. Manage your deductions with QuickBooks Self-Employed .