I am trying to compare two arrays and display which entries are present, and which are not.
For example sake - my two arrays contain the following:
logArray: Test1, Test2, Test3, Test4, Test5
checkArray: Test1, Test2, Test3, Test4, Test5, Test6, Test7
The result I am trying to achieve is the following output:
FOUND: Test1
FOUND: Test2
FOUND: Test3
FOUND: Test4
FOUND: Test5
NOT FOUND: Test6
NOT FOUND: Test7
I think I am close with my code but something is just not right and the NOT FOUND displays a ridiculous amount.
for (int i = 0; i < logArray.length; i++) {
for (int x = 0; x < checkArray.length; x++) {
if (logArray[i].equals(checkArray[x])) {
logsFound = logsFound + 1;
modelFound.addElement("<html><font color=#009933>FOUND: </font> " + logArray[x] + "</html>");
}
}
if (isFound == false) {
logsNotFound = logsNotFound + 1;
modelNotFound.addElement("<html><font color=#FF0000>NOT FOUND: </font> " + logArray[i] + "</html>");
}
}
EDIT: Adjusted as per some comments, and it displays the NOT FOUND correctly now, HOWEVER it'll only display the amount of NOT FOUND if it's within the first array amount. So because my logsArray contains 9 items, but checkArray contains 10 items (as seen under Checklist), it displays 4 total in NOT FOUND. So it's meant to display 2VA.004.01.16 too.
isFound is declared before the for loops
Updated code:
for (int i = 0; i < logArray.length; i++) {
isFound = false;
for (int x = 0; x < checkArray.length; x++) {
if (logArray[i].equals(checkArray[x])) {
logsFound = logsFound + 1;
modelFound.addElement("<html><font color=#009933>FOUND: </font> " + logArray[x] + "</html>");
isFound = true;
}
}
if (isFound == false) {
logsNotFound = logsNotFound + 1;
modelNotFound.addElement("<html><font color=#FF0000>NOT FOUND: </font> " + checkArray[i] + "</html>");
}
}

isFoundassigned?