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));
	EmployeeList.printAll();
	}
}
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());
	count++;
}
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));
	count++;
}
public  void printAll(){
	for(count=0;employees[count]!=null;count++){
		System.out.println(employees[count]);
	}
}
	
}
for(count = 0; count < employees.size; count++){

Thank you ,but can I ask why

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

2/ you have to check before

if(employees!=null)
//and
if(employees.size>0)

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

- null
- one segment,
- n Sergments

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.