我需要通过合并两个对象的几个元素来将两个对象的数组列表合并为第三个数组列表

时间:2019-05-25 06:16:20

标签: java arraylist

for (int i=0; i<=students.size(); i++)
{
if (students.get(i).candidateid == a2.get(i).candidateid)
{
students3.get(i).candidateid = students.get(i).candidateid ;
students3.get(i).teacherid = students.get(i).teacherid ;
students3.get(i).lastname = students.get(i).lastname ;
students3.get(i).firstname = students.get(i).firstname ;
students3.get(i).firstsection = students.get(i).firstsection ;
students3.get(i).secondsection = students.get(i).secondsection ;
students3.get(i).thirdsection = students.get(i).thirdsection ;
students3.get(i).technical = students.get(i).technical ;
students3.get(i).firstsuptest = students.get(i).firstsuptest ;
students3.get(i).secondsuptest = students.get(i).secondsuptest ;
students3.get(i).practical = a2.get(i).practical ;
}    
}

将arraylist学生和a2合并为students3  我正在尝试将已排序的arraylist学生和a2合并到第三个arraylist students3中。如果两个arraylist中的候选键都匹配,则将两个arraylist中的几个元素复制到最终的arraylist中。我需要一种有效的方法来做到这一点,以便最终的arraylist保持排序

0 个答案:

没有答案