list remove duplicates

The list can have repeated data items, and sometimes it needs to be deduplicated. The common one is the secondary loop, and the amount of operation is N*N.

 

We can also use another method to do it through the HashSet class, that is, loop

The data item of the list is added to the set, and the content of the set obtained after the loop is definitely not repeated.

Because the characteristic of set is that the data is not repeated

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326949544&siteId=291194637