aspose file tools*
The moose likes Beginning Java and the fly likes Array Objects question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array Objects question" Watch "Array Objects question" New topic
Author

Array Objects question

David Sundo
Greenhorn

Joined: Nov 13, 2002
Posts: 6
I have a hard time to use the Array Objects.
Basically I would like store 3 String for each line dynamically.
For example: I would like to store in
Object[][] data;
The contents are as followed:
array 1 -->{"toyota", "1988", "green"}
array 2 -->{"honda", "1999", "white"}
Can anyone show me how to store dynamically? I do not want any initilization.
Greatly appreciated! Thank you!
-David Sundo
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
hi david
well, what i think about ur issue is, i observe that u haev information that seem to be related to the car object,
{
Make
Year,
Color
}
and u want to store such information dynamically...
why don't u create an object called,
class Car {
String make;
String year; // OR int??
String color;
}
and use ArrayList (basically List interfaces..) or Vector to add/remove such Car objects. u can do,
Car c1 = new Car("toyota","1982","red");
Car c2 = new Car("honda","1994","green");
...
and ArrayList al = new ArrayList();
al.add(c1);
al.add(c2);
if u have dynamic input u can do,
ArrayList al = new ArrayList() at beginning ofthe program and then at the point u get input write,
al.add(new Car(makeVar1, yearVar2, colorVar3));..
hope it helps..
regards
maulin
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I don't really understand your question, David. What exactly are you trying to accomplish?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array Objects question