473,320 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Set class (order)

11
Hello,

I am using Set class to remove duplicates from an array. The order in the array is important for my work. After removing the duplicates i create another array containing the elements of the Set, but I realize that the order is really different from the first array. Does anyone know how can I have the order of the Set it was inserted first?

The code I am using:
// my is the array containing the information, which can can contain duplicates.
Set mySet = new HashSet(Arrays.asList(my));
// creating new array with the elements of mySet
String [] result = (String[])(mySet.toArray(new String[mySet.size()]));

Thank you in advance,

Mokita
Aug 13 '07 #1
2 1428
JosAH
11,448 Expert 8TB
Have a look at the LinkedHashSet class.

kind regards,

Jos
Aug 13 '07 #2
Mokita
11
Have a look at the LinkedHashSet class.

kind regards,

Jos


Thank you very much for the hint.

Mokita
Aug 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: svilen | last post by:
hi. this was named but it is misleading. i want to have the order of setting items in intrinsic dicts (keyword args, or class attributes, etc). which is, a prdered dict trhat matches the...
23
by: mark.moore | last post by:
I know this has been asked before, but I just can't find the answer in the sea of hits... How do you forward declare a class that is *not* paramaterized, but is based on a template class? ...
9
by: MariusI | last post by:
Consider the following class layout public class Order { public ProductOrder AddProductOrder(/* variables required to create a product order */) { /* Check if the product order can be added...
1
by: beniro | last post by:
Hello, all. I'm implementing LinkPoint API on my site, but I have an error coming up in their code, and I'm wondering if anyone could give me any guidance on this one. Here is the specific error:...
0
by: beniro | last post by:
Hello, all. I'm implementing LinkPoint API on my site, but I have an error coming up in their code, and I'm wondering if anyone could give me any guidance on this one. Here is the specific error:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.