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

Creating arrays of objects

Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
Okay.. simple question for you.
How do I create an array of objects. I really never needed to do this before. I usually created the objects within a HashMap or a HashTable but never put them into an true array.
What's this H2SO4 doing in my fridge?? ( thud )

By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Raajesh Chandran
Ranch Hand

Joined: May 04, 2001
Posts: 103
Just go thru the code.if U r not clear I will inform U in much better way.
class employee {
int empno;
String empname;
double bas_sal;
public employee(int empno, String empname, double bas_sal) {
this.empno =empno ;

public static void main(String args[]) {
employee[] e = new employee[1000];
for(int i=0;i<1000,i++)
e[i] = new employee(i,"raajesh",25000);

Sorry I don't what H2SO4 doing in U'r Fridge.If U got reply me

[This message has been edited by Raajesh Chandran (edited May 05, 2001).]

Alex Ayzin
Ranch Hand

Joined: Apr 10, 2001
Posts: 107
Or if you wanna put it in much simpler form:
Record[] new arrayOfRecords = New Record[100];
Sorry for retyping, just trying to be moree clear(just in case)
I agree. Here's the link:
subject: Creating arrays of objects
It's not a secret anymore!