This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: how to do this ?? should i use array or vector..
It's not a secret anymore!