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