Re: Question about indexing objects
Wednesday, March 23, 2005 01:14 AM
usually when we are going to search something,we need a key which should be unique.
but in your case, keys are repeatble.
To solve your problem, you can store a values in following way
Hashtable ht=new Hashtable();
ht.put(new Hashtable(personal inforamtion about john,single)),married)
normally we should store any item in Hashtable in the format of (key,value) pair.
but in our case keys are "male","single" like that. they are rpeatable.
that's why in the above example, i reversly stored obj,key.
becoz,each object has one idetification mark to diffreretiate from others.
Finally you should collect values from Hashtable. and findout which are all the keys are "male" ,"female" etc.
after that You can have appropriate object corresponding to
what you search.
For example if you want to search "married" means
first collect the values and keys from hashtable as a collection objects.
findout which keys map to "married".
findout corresponding HashTable object.
after that you can easily find out "male" or "female" based on Hashtable object
that you have found in previous search.
and The better way is You can store your informations into DataBase.
and You can retrieve the information you want from
DataBase using JDBC