I am doing an assignment where we have to use an Array List to make an application that store employee info (salary, name, ID #, start date). We were told to create a class for teh records of the employees. I have to make the program remove an entire entry from just the employee ID # which I'm having a hard time figuring out.
//removes entries from record using only ID
String id;
int i;
id = idIn.getText();
below is the code for the creation of the class
//class for employees
class employees{
String first, last, id, date, salary;
employees (String _first, String _last, String _id, String _date, String _salary){
first = _first;
last = _last;
id = _id;
date = _date;
salary = _salary;
}
}
System.out.println(id);
i = records.indexOf(id);
System.out.println(i);
This is the creation of the Array list
//create array for records
ArrayList <employees> records = new ArrayList <employees>();
And this is how entries are added to the list
//add records to array
employees e;
String first, last, id, date, salary;
first = firstIn.getText();
last = lastIn.getText();
id = idIn.getText();
date = dateIn.getText();
salary = salaryIn.getText();
e = new employees (first, last, id, date, salary);
records.add(e);
I get a value of -1 when searching for the index of the ID #
records, or the ID insiderecordsis not of typeString.myList.removeIf(x -> x.getID() == someID);