java - Method to remove duplicates in List -


possible duplicate:
remove duplicates list

is there method in java list can use remove duplicates?

no, there no method on java.lang.list removes duplicates. seems designers expected list not used in scenarios worried duplicates:

unlike sets, lists typically allow duplicate elements. more formally, lists typically allow pairs of elements e1 , e2 such e1.equals(e2), , typically allow multiple null elements if allow null elements @ all. not inconceivable might wish implement list prohibits duplicates, throwing runtime exceptions when user attempts insert them, expect usage rare.

(taken java.lang.list javadoc)

you either need use set or implement own method removing duplicates.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -