dcsimg
Trying to create an array of Hashtable[] arrays
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Steven_Elliott
Posted On:   Monday, December 10, 2001 11:31 AM

Hopefully this won't seem too basic.

I've read through a couple of dissertations on the Java 2 Collection interfaces and feel pretty comfortable. But I am having a problem creating an array of hashtable arrays (i.e. Hashtable[][]).

I am trying to create a multiple array of database execute resultSets. IOW I would like to make several database queries with each result set ( a Hashtable[] ) contained within an array. Thanks for the help

Re: Trying to create an array of Hashtable[] arrays

Posted By:   Jeff_Chamard  
Posted On:   Monday, December 10, 2001 01:48 PM

Hello guys,
I used to get the same problem some months ago.
Here is a quick solutions for Arrays of Hashtable Arrays:

First of all, create an ArrayList (from java.util class), then an hashtable.

- ArrayList itemid = new ArrayList();
- Hashtable items = new Hashtable();


Now you should fill the ArrayList with your items ID or whatever it is.

itemid.add(ITEM_ID_HERE);

[...]

After, you have to fill the hashtable.
Fill them like this:

items.put(ITEM_ID_HERE+"-"+NAME_HERE, VALUE_HERE);

[...]

Now you can get whatever you want using this way:

items.get(itemid.get(inti)+"-price");


N.B. the last sentence gets all the Price for all items. Of course you have to loop and to understand that "inti" is a counter... and "price" is your name (NAME_HERE) you put before in your hastable.

Hope this helps.
Long live to JGuru.



Jeff Chamard

CGI Programmer

Horus Technologies Inc.

http://www.horustechnologies.com

Re: Trying to create an array of Hashtable[] arrays

Posted By:   Steven_Elliott  
Posted On:   Monday, December 10, 2001 12:58 PM

Never mind.


I managed to get my head around the problem.

Great to know jGuru exists, though!
Thanks
Steven Elliott
About | Sitemap | Contact