This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by Henry Wong: You can have an array of Vectors. You can have an array of array of Vectors. You can have a Vector of Vectors. You can have an array of array of Vectors of Vectors of array of array of Vectors...
You can have a collection within a collection, But it is not a good coding practice to keep on tossing collections within collections. It makes your code hard to understand. This is analogous to storing items in pigeonholes without any labelling. To store items use value objects or data objects (as oppose to storing every attribute in an ArrayList or HashMap). Provide wrapper classes around your collection API classes like ArrayList, Hashmap etc
Thank you never used a wrapper class before. What I need to do is create an unlimited amount of "Vectors"(Can be an array) with the vectors being different lengths each time it is run. I tried an array of vectors and ran into problems.
If you are not sure of the exact number of Vectors that you need, then you can use a dynamic structure like an ArrayList which can grow dynamically. (Also unless you have a compelling reason, you can use an ArrayList instead of a Vector).
Joined: Oct 08, 2004
Thanks, I'm working with the arrayList and think it will work.