It's not a secret anymore!
The moose likes Beginning Java and the fly likes Chreating an array of vectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Chreating an array of vectors" Watch "Chreating an array of vectors" New topic

Chreating an array of vectors

rick kinirons

Joined: Mar 24, 2009
Posts: 1
Hey I'm in the middle of creating an aplication which basicly takes in information from the user and stores it in a database. I thought the easiest way of doing that would be to save it in a vector and of sorts and then save it to the database. The aplication must store information about cars and so I thought the easiest way of doing it would be by having an array with each field of the database saved within it and embed this in a vector which could expand for each car added.. Only thing is I haven't really covered how to do this in college and was wondering if anybody knew of any ressources which might be able explain the process to me.. Any help would be greatly appreciated. Thanks, Rick.
Harshit Rastogi
Ranch Hand

Joined: Apr 15, 2008
Posts: 131
Hi ,

First question why do you need vector. IF your application is not multithreaded use arraylist.You can put an arraylist or array in an Arraylist .

I would recommend instead of using newList object create a Car class with all the properties in it . save the data in Car object and add it to the list.

My Techie Blog - Java Questions
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

If you want to save information about a car, the natural thing to do would be to create a Car class to store that information. Creating an array would not make sense in Java. You could certainly have a List of Car objects.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46320
Turning a List to an array is quite easy. A similar question is being discussed at the moment here.
I agree. Here's the link:
subject: Chreating an array of vectors
It's not a secret anymore!