Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!198.186.194.247.MISMATCH!news-out.readnews.com!transit3.readnews.com!nx01.iad01.newshosting.com!newshosting.com!216.196.98.146.MISMATCH!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 05 Sep 2011 07:52:06 -0500 Date: Mon, 05 Sep 2011 05:51:35 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: remove duplicates? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 15 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.204.158 X-Trace: sv3-Vim9AxJ4omGKV8Qra7uu/tF2sp87SM1e5KqcX1aPVRwfS5hjXSANSe/SFDTrz0lEyeXL30wsilGtxDo!+YJhkFttXcOWMPzurG7S9EHAMyJs3CdsyJ5QzDgausas2jaks5PsHUIYJBKrdbx4AkhcZxka0rYf!g59CfU8905ridnXuuh4Na2t2DpySzevDFYhQ32On19Hirlw= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1694 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7575 On 9/5/2011 1:44 AM, bob wrote: > Let's say you have a Vector of String objects. What is the easiest > way to remove duplicates? If you want to preserve the order of first appearance, assuming "vector" is the original data: Set set = new LinkedHashSet(vector); If you don't care about order, you can use HashSet instead of LinkedHashSet. I agree with the suggestion that, if at all possible, you should use a Set instead of the Vector. Patricia