• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing multiple values using a single key in Java 1.2

 
Drew Goldberg
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I was wondering if there is a way to store multiple values for a single key in java 1.2, which I believe means no Generics?

Cheers,

Drew
 
Paul Clapham
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. The usual way is to have the key mapped to a list of values.

(I don't know what Generics has to do with the question... could you expand on that?)
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generics aren't an issue here. In all Java versions the way to go with the existing API is to use a Map with a collection (list, set) as its values.
If you want an easier interface, check out Apache Commons Collections or Google Guava - both have a multi map. However, Google Guava isn't an option for you as it's written using generics, and needs to be heavily modified to get working in Java 1.2. You should theoretically be able to recompile Apache Commons Collections using a Java 1.2 compiler, as it doesn't use generics (yet).
 
Drew Goldberg
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul and Rob for your help!


Cheers,

Drew
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic