File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes how to do this ?? should i use array or vector.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to do this ?? should i use array or vector.." Watch "how to do this ?? should i use array or vector.." New topic

how to do this ?? should i use array or vector..


Joined: Sep 27, 2001
Posts: 4
i got a question on whether i should use array or vector.. i need to define an multidimensional array..
i.e. array[name][money][time]..
but i do not know the size of the array.. i was reading that i can use vector or arraylist.. but i do not know if vector is able to take in the information like the above.. pls help.. if u can provide me with the starting code on how to declare vector and how to add the elements into the vector/arraylist.. i will be veri grateful..
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 776

I would suggest that you stick with ArrayList.
Vector's methods are synchronized - thus there might
be a performance hit.



Joined: Sep 27, 2001
Posts: 4
but how do i declare an arraylist with 3 different "headings".. for example, using array... i could do this
but for arraylist .. how do i define the arraylist to create the same functionalitiy as the array...
John Sinues
Ranch Hand

Joined: Feb 21, 2000
Posts: 52
Could you store this information (name, address, telephone) in
a class then place the class in the ArrayList?
public class PersonInfo {
private String name;
private String address;
private String telephone;
PersonInfo( String name, String address, String telephone) { = name;
this.address = address;
this.telephone = telephone;
ArrayList info = new ArrayList();
info.add( new PersonInfo("name","address","phone") );
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Please change your name to be compliant with JavaRanch's naming policy.
Your ID should be 2 separate names with more than 1 letter each. We really want this to be a professional forum and would prefer that you use your REAL name.
PS, if your name is not valid you do NOT qualify for the book giva away.

"JavaRanch, where the deer and the Certified play" - David O'Meara
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: how to do this ?? should i use array or vector..
jQuery in Action, 3rd edition