An alternative to the Vector container

Ok I have been using Vector arrays for storing data objects. Inserting them and recalling them from a database for example. I believe vectors have a limit of something like 900 entries allowed in them. A problem I forsee in the future. So to this end I need an alternative container. Any suggestions?
bhessionAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

colr__Commented:
Take a look at ArrayList
0
enachemcCommented:
vector = synchronized ArrayList
if you do not use threads, use ArrayList
ArrayList and Vector do not have a maximum size (they auto increase their capacity, which is only limited by the VM size)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
colr__Commented:
Yeh, I'd never heard about the max size issue either tbh. ArrayList was just an alternative to Vector. There is a whole bunch of classes in the collections package that might be of use to you. You might also want to consider a custom data structure, depending on your usage.
0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

bhessionAuthor Commented:
Ok can you point me to a good place to learn how to use this array list. Also as I am pulling from a very large database maybe 100,000 rows should I be concerned by using an ArrayList?
0
colr__Commented:
No, there are no size limits on these structures. And you use ArrayList in the same way you have done a Vector:

List<String> myList = new ArrayList<String>();
myList.add("value");

However, you should not be pulling such large numbers at the same time. If you need to actually work on such a large data set you should pull the data in stages - pull 10 rows at a time, process it, then move on to the next 10 rows until you are done. This would optimise the process as otherwise you are always going to run into possible memory and performance problems.
0
colr__Commented:
... plus pulling 100,000 from your database is going to grind it to a halt, nevermind your application logic.
0
enachemcCommented:
if you know an approximative number of records to store, use the following contructor:
List<String> myList = new ArrayList<String>(no_of_items);

no_of_items should exceed the required capacity (otherwise, ArrayList will expand its size, but at a cost of slowing you down a tiny bit)
0
bhessionAuthor Commented:
Sorry enachemc, could you expand on the below so I could better understand what you mean.

"no_of_items should exceed the required capacity (otherwise, ArrayList will expand its size, but at a cost of slowing you down a tiny bit)"

I'm unsure as to what your saying. Thanks
0
colr__Commented:
When you construct an ArrayList using the constructor new ArrayList(5), this sets up the list with an initial expected size of 5. The implementation of ArrayList uses an array in the background, so using this constructor sets the array size to 5. If you try and add a 6th item to the list, this results in a new array is constructed, the values copied across and the new value added - this alll happens at a cost because you are copying the array. Setting the initial size means you can potentially avoid this copying step.
0
enachemcCommented:
that is true
so ensure a correct estimate
an incorrect estimate would still work, but 0.1% slower
0
Mick BarryJava DeveloperCommented:
There is no size restriction on Vectors, they can hold the same amount an ArrayList does.
0
bhessionAuthor Commented:
Thanks guys.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.