Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating arrays of objects

 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
-Dale
------------------
What's this H2SO4 doing in my fridge?? ( thud )
 
Raajesh Chandran
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!!
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 ;
this.empname=empname;
this.bas_sal=bas_sal;
}
}

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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
Regards,
--Alex
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic