File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes can you have an array of vectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "can you have an array of vectors" Watch "can you have an array of vectors" New topic
Author

can you have an array of vectors

Donna Bachner
Ranch Hand

Joined: Oct 08, 2004
Posts: 109
or an array of array's I think I just solved my problem but can you have an array of vectors?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yes, you can. Did you get some error messages when you tried it or what?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18765
    
  40

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 ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Donna Bachner
Ranch Hand

Joined: Oct 08, 2004
Posts: 109
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

Joined: Oct 08, 2004
Posts: 109
thankyou everyone I got it working!!!
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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();
v.add(v);


There is no emoticon for what I am feeling!
ak pillai
author
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
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


java j2ee job interview questions with answers | Learn the core concepts and the key areas
Donna Bachner
Ranch Hand

Joined: Oct 08, 2004
Posts: 109
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.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
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

Joined: Oct 08, 2004
Posts: 109
Thanks, I'm working with the arrayList and think it will work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can you have an array of vectors