We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Removing doublettes from a collection/array

jespersahner
jespersahner asked
on
Medium Priority
270 Views
Last Modified: 2010-03-31
Hi!

Does Java have a method for removing doublettes from a collection/array?

Regards,
Jesper
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
Add the m toa Set
He means:  create a Set from your collection and ................ de doublettes will vanish.

;JOOP!
CERTIFIED EXPERT
Top Expert 2016
Commented:
Yes.

Set unique = new HashSet(Arrays.asList(array));

Set unique = new HashSet(collection);

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
->CEHJ: Thanks!
CERTIFIED EXPERT
Top Expert 2016

Commented:
:-)
Why a grade of B? This answer was perfect!

;JOOP!
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
that'll still leave the dupes in your original collection/array btw.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.