The code seems correct and straight forward to me, I'm using the basic indexOf method for an array i created.
Why won't this code:
public int indexOf(X s)
{
for (int i = 0; i <= arr.length-1; i++)
{
if (arr[i] == s)
{
return i;
}
}
return -1;
}
pass this test:
@Test
public void testIndexOf()
{
BetterArray<String> b = new BetterArray<String>();
for (int i = 0; i < 20; i++)
b.add("str" + i);
assertEquals(0, b.indexOf("str0"));
assertEquals(19, b.indexOf("str19"));
assertEquals(-1, b.indexOf("not found"));
}