dcsimg
What is the best choice among Hashtable and Vector
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, April 5, 2001 05:15 AM

Hi all
i am developing a web based project. i want to display the result in a
table format.i have two options like put the result in a Hashtable or in a Vector and display it in a table format in my jsp.Which one will be the best option in all respect?

thanks in advance
rajesh

Re: What is the best choice among Hashtable and Vector

Posted By:   Luigi_Viggiano  
Posted On:   Friday, April 6, 2001 01:46 AM

I suggest you to avoid Hashtable and Vector too: see Legacy classes on collection framework.
In the context you've explained, I suggest you to use an ArrayList, is lighter in terms of memory than a "Hash"Map and similar to a Vector.

HashMap could be used if you want to give a NAME to each element of the results... I think should be ugly... Maybe could be used if the name of each element is the Primary Key.

Re: What is the best choice among Hashtable and Vector

Posted By:   Michael_Wax  
Posted On:   Thursday, April 5, 2001 08:57 AM

I will go out on a limb and guess that you really want to use an ArrayList. The ArrayList is like a Vector, but its methods are not synchronized (for multithreaded access), so it is much faster than a Vector. If I were creating a table, I would use an ArrayList of container objects, each of which represents a row in the table. A nice thing about an ArrayList is that you can use Collections.sort to sort the elements in any way you like.



I would use a HashMap (over the synchronized Hashtable) if my table had only two columns, or if there were one column whose values would serve as the keys for retrieving each row.

About | Sitemap | Contact