aspose file tools*
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 Java 8 in Action this week in the Java 8 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
Author

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

Roy
Greenhorn

Joined: Sep 27, 2001
Posts: 4
hi,
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: 761

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


Regards,

Pho
Roy
Greenhorn

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
array[name][address][telephone]..
but for arraylist .. how do i define the arraylist to create the same functionalitiy as the array...
thanks..
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) {
this.name = name;
this.address = address;
this.telephone = telephone;
}
}
:
:
:
ArrayList info = new ArrayList();
info.add( new PersonInfo("name","address","phone") );
:
:
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Roy,
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.
Thanks,
Cindy
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to do this ?? should i use array or vector..
 
Similar Threads
IllegalMonitorStateException
Convert a String[] array
ArrayList & Vector
Arrays, Vectors and Tables - Adding and Deleting objects
ArrayList & Vector