Java 删除数组列表中的项

Java 删除数组列表中的项,java,arraylist,Java,Arraylist,我正在做一项任务,我们必须使用数组列表来创建一个存储员工信息(工资、姓名、ID#、开始日期)的应用程序。我们被告知为员工的记录创建一个类。我必须让程序只从员工ID中删除一个完整的条目,我很难弄清楚这一点 //removes entries from record using only ID String id; int i; id = idIn.getText(); 下面是创建类的代码 //class for employees class employees{

我正在做一项任务,我们必须使用数组列表来创建一个存储员工信息(工资、姓名、ID#、开始日期)的应用程序。我们被告知为员工的记录创建一个类。我必须让程序只从员工ID中删除一个完整的条目,我很难弄清楚这一点

//removes entries from record using only ID
    String id;
    int i;
    id = idIn.getText();
下面是创建类的代码

  //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);
这是数组列表的创建

//create array for records
ArrayList <employees> records = new ArrayList <employees>();

在搜索ID的索引时,我得到了-1的值35;

我的在线老师告诉我,“当你为employee对象创建类时,你可能已经为ID包含了一个整数参数。你必须搜索每个记录(基本上是每行)要找到正确的ID,您可以使用for循环遍历从0到大小1的每个员工。如果找到ID,则循环中的数字表示arrayList中员工的索引值。然后您可以删除该值。“但我不确定他是什么意思,另外,我的ID#是一个字符串……这意味着ID不在
记录中,或者
记录中的ID不属于
字符串类型。请显示数组列表构造的代码。如果记录是您的ArrayList,则这不是您使用该ID搜索项目的方式。您必须使用迭代器遍历列表,检查id,然后删除(或使用流间接删除)。
myList.removeIf(x->x.getID()==someID)
//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);