I currently have some array lists and am trying to transfer some elements into a different array.
Here's what I have so far:
//create array separate from user input to remove duplicates
ArrayList<String> idsWithoutDuplicates = new ArrayList<String>();
for (int i = 0; i < missionIds.size(); i++){
if (idsWithoutDuplicates.contains(missionIds.get(i))== false)
idsWithoutDuplicates.add(missionIds.get(i));
}
//search for mission numbers within array of array
for (int k = 0; k < idsWithoutDuplicates.size(); k++ ){
int idSize=0;
for (int employeeName = 0; employeeName <ids.size(); employeeName++){
for (int employeeId = 0; employeeId <ids.get(employeeName).size(); employeeId++){
/* when id is located, use the employee array to locate the other missions to
* which they belong */
if (ids.get(employeeName).get(employeeId).equals(idsWithoutDuplicates.get(k))){
for (employeeId = 0; employeeId < ids.get(employeeName).size(); employeeId++){
ArrayList<String> count = new ArrayList<String>(); // ---> separate array for each employees total missions
if (ids.get(employeeName).get(employeeId).equals(idsWithoutDuplicates.get(k)) == false &&
count.contains(ids.get(employeeName).get(employeeId))== false){
count.add(ids.get(employeeName).get(employeeId));
idSize += count.size();
for (int i= 0; i < count.size(); i++){
System.out.print(count.get(i));
}
}
}
}
}
}
System.out.println(idsWithoutDuplicates.get(k) + "\t " + idSize);
}
The last if statement is trying to eliminate any duplicates with the contains condition, but this doesn't seem to work. I've tried converting 'count' to a set but this didn't work either.