Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What kind of List<?> will automatically eliminate duplicates [duplicate]

Tags:

java

What kind of List will automatically eliminate duplicates when they are added.

e.g. for a List if I add 1,2,3,4,5,1,2,3 = the List should just contain just 1,2,3,4,5

like image 933
user339108 Avatar asked Sep 24 '10 07:09

user339108


People also ask

How do I remove duplicates in a pivot table?

Go to the Design tab ➜ select Subtotals ➜ select Do Not Show Subtotals. What is this? You now have a pivot table that mimics a tabular set of data! Pivot tables only list unique values for items in the Rows area, so this pivot table will automatically remove any duplicates in your data.

Does ArrayList remove duplicates?

The arraylist contains duplicate elements. Here, we have used the LinkedHashSet to create a set. It is because it removes the duplicate elements and maintains insertion order. To learn more, visit Java LinkedHashSet.


1 Answers

If you want to eliminate duplicates, use Set

like image 55
Nivas Avatar answered Sep 28 '22 08:09

Nivas