This content has been marked as final. Show 5 replies
While it doesn't say explicitly, it seems like Vector implements an array-backed list similar to what ArrayList does. My guess is that you will not notice any difference between the two of them.
If you're concerned with speed, both of them are the correct choice, particularly in this case, where you do not need to expand the array beyond the initial number of rows. Make sure when you declare your ArrayList or Vector that you specify the initial size to be the same as your that from your ResultSet. This prevents the ArrayList/Vector from having to resize itself when you add more stuff than it can handle at the time (both a time and memory-costly operation). Since both ArrayList and Vector are array-based, they're both fast for later sorting/reference operations. (You just don't want a linked list implementation!)
You might also want to consider an array for your purposes, if you don't need the added functionality that the data structures provide. It makes for a bit more lightweight implementation.
Frankly, though, you shouldn't have to worry too much with only 50,000 elements (unless they're all huge blobs or something).
Ok, first do a search ArrayList vs. Vector. We had so many threads about this.
If you aren't using a multi threaded environment go for ArrayList, otherwise use a Vector.
Oh that's right. PhHein is correct. A Vector is a synchronized data structure so it is better for multi-threaded applications where many threads need to concurrently access and modify the Vector. I'm not sure if this incurs a performance cost.
Anthop wrote:It does, a slight one. But Vector is also an outdated class and it's preferred to use ArrayList, or when needing a synchronized list, using Collections.synchronizedList() to create one out of an ArrayList (or any list that suits you).
I'm not sure if this incurs a performance cost.
Thanks a lot guys....I will surely go for ArrayList.Untill i come up with any further queries or issues "HAPPY CODINGGG..."