The Artima Developer Community
Sponsored Link

Java Buzz Forum
Remove Duplicates from a List

1 reply on 1 page. Most recent reply: Aug 8, 2011 3:57 AM by Naveen Vaddepalli

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Goldy Lukka

Posts: 1008
Nickname: xyling
Registered: Jan, 2004

Goldy Lukka is a Java Developer and an Entrepreneur. He is Founder of xyling.com.
Remove Duplicates from a List Posted: Aug 1, 2006 6:44 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Goldy Lukka.
Original Post: Remove Duplicates from a List
Feed Title: Xyling Java Blogs
Feed URL: http://www.javablogs.xyling.com/thisWeek.rss
Feed Description: Your one stop source for Java Related Resources.
Latest Java Buzz Posts
Latest Java Buzz Posts by Goldy Lukka
Latest Posts From Xyling Java Blogs

Advertisement
Thanks to Brian Kuhn (refer title of this post) for the following piece of code to to make a List contain unique items only.

On a side thought, would this chew up lot of cpu/memory? Feel free to post your comments.

public List removeDuplicates(List items) {
Set set = new LinkedHashSet();
set.addAll(items);
return new ArrayList(set);
}

[Resource-Type: Source Code; Category: Java/J2SE; XRating: 4]

Read: Remove Duplicates from a List


Naveen Vaddepalli

Posts: 1
Nickname: navin8055
Registered: Mar, 2011

Re: Remove Duplicates from a List Posted: Aug 8, 2011 3:57 AM
Reply to this message Reply
Can we do this with out using Set Interface or HashSet Class..???

Flat View: This topic has 1 reply on 1 page
Topic: Fundamental Components in a Distibuted System Previous Topic   Next Topic Topic: Best Of The Week - 2011 - W30

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use