2

i need to store non unique key value pair like in an application which can only be compiled with java 1.4. It should look like :

{"key1"=>"value1",
"key2"=>"value2",
"key3"=>"value3",
"key3"=>"value4"
}

thanks in advance

ankit
  • 295
  • 4
  • 14
  • 7
    `Map>` not good enough? Also, Java 1.4? What the …?! It’s now ten years old, and outdated for 8 years. That’s way beyond a software’s best-before date. – Konrad Rudolph Jul 15 '12 at 19:03
  • i know it sucks to use java 1.4 ... but it's a legacy app which is still breathing – ankit Jul 15 '12 at 19:21
  • 1
    Well, can’t the legacy app be compiled under newer Java versions? And if it can’t – how much effort would it be to bring its codebase up to date? After all, Java is almost completely backwards compatible. – Konrad Rudolph Jul 15 '12 at 19:23
  • @KonradRudolph There are application servers out there that run on Java 1.4. There really is no help. – Marko Topolnik Jul 15 '12 at 20:27

1 Answers1

1

In core java, I think you are stuck with storing arrays or lists as the values of a Map interface (hashmap). You might also consider answers here: Map implementation with duplicate keys

What are the semantics of asking for a duplicate key?

Community
  • 1
  • 1
UberAlex
  • 3,477
  • 4
  • 22
  • 22