Ok I'm writing this on the assumption that you wrote getSize(). If this is so how are you holding empty spaces? Like if the array were empty (getSize() should return zero) then whats in the ten spaces? My thinking is that getSize() isn't doing what you think it's doing and it's always returning that every space is used so you're always going to the end of the array and then purposefully going one beyond with your code.
So assuming the array has ten slots getSize() is returning ten, aryIndex gets up to [9] (the tenth spot) and then inside your first if statment you're trying to access [10] the non-existant eleventh space of the array here:
(I'm essentailly saying here that joe_bruin was right but perhaps too brief in saying why)
Code:
if(ary[aryIndex] > ary[(aryIndex+1)])
{
asdf = ary[ ary[(aryIndex+1)] ];
}
Maybe I'm missing something significant here but thats my best guess for now.
I would suggest restructuring the whole algorithm where instead of comparing the present against the next value you compare the present against the past highest value.
Code:
int biggest(int[] ary)
{
int cur_space;
int largest = 0;
//this assumes the first space is the largest for no reason
//what-so-ever.
for(cur_space = 0; cur_space < ary.length; cur_space++)
{
if(ary[cur_space] > ary[largest])
{
largest = cur_space;
}
}
return ary[largest];
}
If I've had a massive brain failure and this doesn't work or you don't get how it does or is supposed to work let me know.