Beginner in Android development. My code crashes. I have made a simple Java method like a inArray function in php.
private ArrayList<Long> inArray(int array[], int searched)
{
ArrayList<Long> ans = new ArrayList<Long>();
for(int i = 0; i <= array.length; i++)
{
if (array[i] == searched)
{
ans.add((long) i);
}
}
return ans;
}
It doesn't work on this stage
if (array[i] == searched)
How can i Compare them ? I have tried many things but the code just keeps crashing. Thank you very much.