I have no idea why this isn't working.
public static int getMaxPosition(ArrayList<Integer>list)
{
int max=list.get(0);
int maxPos=0;
int curr;
int c;
for (c=0; c<list.size(); c++);
{
curr=list.get(c);
if (curr>max);
{
maxPos=curr;
max=curr;
}
}
return maxPos;
}
This block of code gives a runtime error (IndexOutOfBoundsException) at the line curr=list.get(c);
, and I can't find any good reason for it.
for (int curr : list)
instead of messing around with an index.