Here I am creating the objects and try to print them,I have differnt classes for date and Employee.The objects EmplObj and EmplObj2 ,are created but I have problem when I tried to print them ,it is printing only the first one

public class tester {
public static void main(String args[]){ 
	EmployeeList EmplObj=new EmployeeList();
	EmplObj.addEmplyee("Steve",34,45,new Date(1,1,2011));
	EmployeeList EmplObj2=new EmployeeList();
	EmplObj2.addEmplyee("Jenifer",35,45,new Date(1,3,2011));
public class EmployeeList {
int capacity; //The capacity of the list
static int count=0; //The number of the employees currently in the list
Employee[] employees;

public EmployeeList(){
	 employees=new Employee[5];
public EmployeeList(int capacity) {
	 employees=new Employee[capacity];
public  void addEmployee(Employee e){
	employees[count]=new Employee();
public void addEmplyee(String name,double hours,double hourlyRate,Date date){
	employees[count]=new Employee(name,hours,hourlyRate,new Date());
public void addEmplyee(String name,double hours,double hourlyRate,int year,int month,int day){
	employees[count]=new Employee(name,hours,hourlyRate,new Date(day,month,year));
public  void printAll(){

Edited 5 Years Ago by kukuruku: n/a

1/ but be sure that overRide both voids with name addEmplyee, because each returs different value

2/ you have to check before


to OP, because you put data to 2D array, and this array canbe

- null
- one segment,
- n Sergments

This article has been dead for over six months. Start a new discussion instead.