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 Array Objects question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array Objects question" Watch "Array Objects question" New topic

Array Objects question

David Sundo

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,
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();
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..
Dirk Schreckmann

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:
subject: Array Objects question
It's not a secret anymore!