We are working on generics which requires us to have an array of AnyType (the driver implements an array of strings then integers). One of the functions is a boolean function called 'remove' which finds 'x' and removes it, then it returns true. It has no issues finding and removing a string but can't seem to find ints. Why is this?
the code is
public boolean remove(AnyType x)
{
for(int i = 0; i < length; i++)
{
if(arr[i] == x)
{
for(int j = i; j < length - 1; j++)
{
arr[j] = arr[j + 1];
}
length--;
return true;
}
}
return false;
}