Tim Walsh wrote:Could somebody please explain this method for me in a bit of detail
public int search(String EmployeeNumberIn)
{
for(int i = 0; i < total; i++)
{
Employee employeeAcc = employees[i];
String employeeNum = employeeAcc .getEmployeeNumber();
if(employeeNum .equals(EmployeeNumberIn))
{
return i;
}
} return -999;
}
I think, employees is an array of Employee, and
total is length of that array. Also, I think they are declared as class level variables as I do not see them declared in search method.
The purpose of this method looks like searching an employee by employee number. It(for loop) goes through each employee record, retrieves employee number and compare it against inputted employee number(
EmployeeNumberIn). If it finds the match, it returns position in array otherwise returns -999, which I think is treated as error code.
This code looks like small part of a bigger program. Did you run that program? What you do NOT understand? Ask specific question.