Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Removing doublettes from a collection/array

Posted on 2006-03-31
7
Medium Priority
?
257 Views
Last Modified: 2010-03-31
Hi!

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

Regards,
Jesper
0
Comment
Question by:jespersahner
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 16342770
Add the m toa Set
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16342982
He means:  create a Set from your collection and ................ de doublettes will vanish.

;JOOP!
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 150 total points
ID: 16343016
Yes.

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

Set unique = new HashSet(collection);
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jespersahner
ID: 16343260
->CEHJ: Thanks!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16343320
:-)
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16343438
Why a grade of B? This answer was perfect!

;JOOP!
0
 
LVL 92

Expert Comment

by:objects
ID: 16346689
that'll still leave the dupes in your original collection/array btw.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question