ArrayIndexOutOfBoundExeption
ok, i have these two methods i am trying to use on an array of integers(arranged in ascending order)
publicvoid removeFirst(int newVal)
{
list[this.search(newVal)] = 0;
if(this.search(0) != -1)
{
for(int i=this.search(0); i<numElements-1; i++)
list[i] = list[i+1];
numElements--;
}
}
publicvoid removeAll(int newVal)
{
for(int i=0; i><numElements; i++)
this.removeFirst(newVal);
the removeFirst method removes the first occurence of the value in the parameter. Also, within the class there is a search method that returns the location of the first occurence of the value in its parameter. Now, the removeFirst works and it will replace the value with 0 and shift everything down so that 0 no longer exists. The removeAll method is supposed to do the same thing except it is supposed to remova all of the occurences. Although whenever I invoke it it gives the ArrayIndexOutOfBoundExeption error. I know there is conflict with the removeFirst method being used in the for loop of the removeAll method, since the removeFirst works by itself but not the second method. Maybe some bad counting logic in numElements? I am trying to figure it out but its not working. Can someone help?>

