This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Arrays of objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Arrays of objects" Watch "Arrays of objects" New topic
Author

Arrays of objects

Paul Baker
Greenhorn

Joined: Feb 05, 2002
Posts: 6
I need to create an array of two objects, one object will be an instance and the other object will be the occurance of that instance. I forget how to send these two objects of different types into the array.
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
Can you post your code here?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Do you mean that one will be the name of the class and the other will be an object of that class?
Object [][]myArray = new Object[][];
Then you can do
WhateverClass myObj = new WhateverClass();
myArray[0][0] = "WhateverClassName";
myArray[0][1] = myObj;
etc.
[ February 05, 2002: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
 
 
subject: Arrays of objects
 
Similar Threads
create instance variable
Function returning two reference variables
assoication class .....
Another garbage collection question
Shared resource synchronization