I'm trying to get the right output for the methods "contain" and "lastIndexOf" using String, but it won't give me the right output for those, in that case, false or true for "contain" and the position of the element for "lastIndexOf". How can I do that please ? Thanks very much.
public class Employee {
public static final int size = 0;
String firstName;
String surname;
int yearOfBirth;
String PPSNumber;
String email;
String phoneNumber;
public Employee(String firstName, String surname, int yearOfBirth, String PPSNumber, String email, String phoneNumber) {
this.firstName = firstName;
this.surname = surname;
this.yearOfBirth = yearOfBirth;
this.PPSNumber = PPSNumber;
this.email = email;
this.phoneNumber = phoneNumber;
}
}
//____________________________________________________//
import java.util.ArrayList;
public class EmployeeManagement {
public static void main(String[] args) {
ArrayList<Employee> employeeList = new ArrayList<>();
employeeList.add(new Employee("Charlie", "Charles", 1991, "234567b", "charlie@b.ie", "7654321"));
employeeList.add(new Employee("David", "Davies", 1992, "5213452d", "david@d.ie", "352135613"));
employeeList.add(new Employee("Levi", "Silva", 1990, "1234", "Levi@b.ie", "333333"));
employeeList.add(new Employee("Gus", "Silva", 1993, "4321", "Gus@b.ie", "444444"));
for (Employee getName : employeeList) {
System.out.print(getName.firstName + ", ");
}
System.out.println(" ");
// contains(Employee)
Employee Emp = new Employee("Gus", "Silva", 1993, "4321", "Gus@b.ie", "444444");
System.out.println("Contains String: " + employeeList.contains(Emp)); // can't make give me the right contain answer
// lastIndexOf()
Employee Charlie1 = new Employee("Charlie", "Charles", 1991, "234567b", "charlie@b.ie", "7654321");
System.out.println("lastIndexOf: " + employeeList.lastIndexOf(Charlie1)); // can't find the lastIndexOf
}
}