Nabdreas
Nabdreas

Reputation: 3467

Duplicate strings in ArrayList of object

I have looked around few examples and cant get my head around it.

I have an List of object and there are some duplicate IDs(strings) in some of those object. What i am trying to do is to go through that list, pick IDs and remove object with duplicate ID and only keep one of them I am feeling rather dump at the moment.

Upvotes: 0

Views: 70

Answers (1)

code monkey
code monkey

Reputation: 2124

You could try this:

List<String> list;
List<String> newList = new ArrayList<String>(new LinkedHashSet<String>(list));

Upvotes: 2

Related Questions