我正在从 2 个数组列表中检索元素并循环和比较它们。有没有更好的方法来循环这个?它有点慢,似乎效率不高
String Name = employee.get(0).getEmpName();
for(int i = 0; i < employee.size(); i++)
{
if (Name.equals(employee.get(i).getEmpName()))
{
for (int j = 0; j < employer.size(); j++)
{
if (Name.equals(employer.get(i).getEmpChoice()) && (employers.get(j).getCompChoice() == 1))
{
if (!Test.contains(Name) ||
!Test.contains(employers.get(j).getCompName()))
{
Test += Name + employers.get(j).getCompName() + "\n";
}
}
}
}
else
{
Name = employees.get(i).getEmpName();
i--;
}
}