• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to strore duplicate key data in java

 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
I just want to know is there any data structre proivide by java in which I can store given dada
I can't use any class of MAP interface because it always ask for unique keys. so please sugest me how to store t his type of data

Data has to store

1100 JAVA
1200 J2EE
1300 JAVA,J2EE
1100 JAVA,J2EE,J2ME
1200 TOMCAT,J2EE,J2ME
1400 WEBSERVER,TOMCAT
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would a simple Set of little objects work for you?

You could put the same code into many different items and put them all in the set. To find all the descriptions that match code iterate the set and look for code matches.

There is much fun to be had here. Add a constructor with code & description parameters to make creating these a little easier. Change the variables to private and add getters (no setters) to make nice immutable items. Add a compareTo method and put these into an ordered set or list ... could that speed up searching?

Any of that help?
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot something I've actually used many times ... a map of lists. This is not quite Java but I hope you can see the idea ...
 
reply
    Bookmark Topic Watch Topic
  • New Topic