• Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing key/Value pair without using collection framework  RSS feed

 
Gangadhararao Bommasani
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

For example, take English dictionary it contains data in following format.

god:Any supernatural being worshipped as controlling some part of the world or some aspect of life or who is the personification of a force
apple:Fruit with red, yellow or green skin and sweet to tart crisp whitish flesh
applaud:Clap one's hands or shout after performances to indicate approval
actual:Presently existing in fact and not merely potential or possible

I want to store key/value pair without using any Collections framework classes.

sample program



My Question is, Is there any better to handle key/value pair without using any collection framework classes?

Thanks,
Gangadhar
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you want to use the Collection framework? This sounds like the job for a Map. By deciding to not use the Collection framework you are not even considering proper solutions like HashMap, TreeMap or even java.util.Properties. The latter extends Hashtable which is a Map implementation so part of the Collection framework.
 
Gangadhararao Bommasani
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct.

However, Is there a way to handle key/value without depending on collection Framework?


-Gangadhararao Bommasani
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gangadhararao Bommasani wrote:
However, Is there a way to handle key/value without depending on collection Framework?


Sure. Write your own. Have a node class that refers to a key and value. This can be held in an array, and managed, like arraylist. This node can contain references to other nodes, and managed, like linkedlist. Or you can have an array of linked lists, like hashmap, etc. etc. etc.

Henry
 
Sha Jar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gangadhararao Bommasani wrote:
However, Is there a way to handle key/value without depending on collection Framework?


No.

Just kidding. Of course there is. Just start developing your own.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!