In this segment of code i am searching an Array list with the contents of:
[1,1,2,1,2,1,1,1,1,1,1,1,1,1,1]
I wrote the code to find the indices of the highest values in the ArrayList and then append those indices to a new Arraylist called
int high = findRelevance.get(0);
ArrayList<Integer> IndicesOfHighest = new ArrayList();
for (int iiii = 0; iiii < findRelevance.size(); iiii++)
{
if (findRelevance.get(iiii) > high)
{
IndicesOfHighest.clear();
IndicesOfHighest.add(iiii);
}
if (findRelevance.get(iiii) == high)
{
IndicesOfHighest.add(iiii);
}
}
I would expect to get in return: [ 2, 4 ] but i instead get:
[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]