Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7575
| Date | 2011-09-05 05:51 -0700 |
|---|---|
| From | Patricia Shanahan <pats@acm.org> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: remove duplicates? |
| References | <c299b494-241e-481f-b993-a6272f15b915@j1g2000yqn.googlegroups.com> |
| Message-ID | <hIidnatVAblrWPnTnZ2dnUVZ_tKdnZ2d@earthlink.com> (permalink) |
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<String> set = new LinkedHashSet<String>(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
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
remove duplicates? bob <bob@coolgroups.com> - 2011-09-05 01:44 -0700 Re: remove duplicates? RedGrittyBrick <RedGrittyBrick@spamweary.invalid> - 2011-09-05 10:23 +0100 Re: remove duplicates? Stanimir Stamenkov <s7an10@netscape.net> - 2011-09-05 12:36 +0300 Re: remove duplicates? rossum <rossum48@coldmail.com> - 2011-09-05 12:46 +0100 Re: remove duplicates? Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-05 08:38 -0400 Re: remove duplicates? Patricia Shanahan <pats@acm.org> - 2011-09-05 05:51 -0700 Re: remove duplicates? Roedy Green <see_website@mindprod.com.invalid> - 2011-09-05 11:07 -0700
csiph-web