I have to remove duplicated objects in a List. It is a List from the object Blog that looks like this:
public class Blog {
private String title;
priv
Make sure Blog
has methods equals(Object)
and hashCode()
defined, and addAll(list)
then to a new HashSet()
, or new LinkedHashSet()
if the order is important.
Better yet, use a Set
instead of a List
from the start, since you obviously don't want duplicates, it's better that your data model reflects that rather than having to remove them after the fact.