aspose file tools
The moose likes Beginning Java and the fly likes Storing key/Value pair without using collection framework Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Storing key/Value pair without using collection framework" Watch "Storing key/Value pair without using collection framework" New topic
Author

Storing key/Value pair without using collection framework

Gangadhararao Bommasani
Greenhorn

Joined: Dec 28, 2009
Posts: 11
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

Joined: Oct 27, 2005
Posts: 19232

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.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Gangadhararao Bommasani
Greenhorn

Joined: Dec 28, 2009
Posts: 11
You are correct.

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


-Gangadhararao Bommasani
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16815
    
  19

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Sha Jar
Greenhorn

Joined: Mar 02, 2010
Posts: 23
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Storing key/Value pair without using collection framework
 
Similar Threads
hast table and unlimited looping
Problem with Treemaps
Help
Doubt about StringTokenizer !!
using doubleToString