Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Paul Clapham
• Ron McLeod
• Jeanne Boyarsky
• Tim Cooke
Sheriffs:
• Liutauras Vilda
• paul wheaton
• Henry Wong
Saloon Keepers:
• Tim Moores
• Tim Holloway
• Stephan van Hulst
• Carey Brown
• Frits Walraven
Bartenders:
• Piet Souris
• Himai Minh

# can you have an array of vectors

Ranch Hand
Posts: 109
• Number of slices to send:
Optional 'thank-you' note:
or an array of array's I think I just solved my problem but can you have an array of vectors?

Marshal
Posts: 27211
87
• Number of slices to send:
Optional 'thank-you' note:
Yes, you can. Did you get some error messages when you tried it or what?

author
Posts: 23919
142
• Number of slices to send:
Optional 'thank-you' note:
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...

Henry
[ March 10, 2006: Message edited by: Henry Wong ]

Donna Bachner
Ranch Hand
Posts: 109
• Number of slices to send:
Optional 'thank-you' note:
When I go to declare the vector I get an error it says it is looking for ]? Here is the code

Vector POI[i] = new Vector();
POI is the array i is the counter. How do I declare the vector?

Donna Bachner
Ranch Hand
Posts: 109
• Number of slices to send:
Optional 'thank-you' note:
thankyou everyone I got it working!!!

Ranch Hand
Posts: 1780
• Number of slices to send:
Optional 'thank-you' note:

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...

What's this?

Vector v = new Vector();

author
Posts: 288
• Number of slices to send:
Optional 'thank-you' note:
Just a suggestion:

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

Donna Bachner
Ranch Hand
Posts: 109
• Number of slices to send:
Optional 'thank-you' note:
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.

Ranch Hand
Posts: 2412
• Number of slices to send:
Optional 'thank-you' note:
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).

Donna Bachner
Ranch Hand
Posts: 109
• Number of slices to send:
Optional 'thank-you' note:
Thanks, I'm working with the arrayList and think it will work.

 And then we all jump out and yell "surprise! we got you this tiny ad!" free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter