where's the error

hey all, plz if any one can tell me where is the error in this method, its giving me arrayOutOfBounds error:

;

for(int i=0; i<arr.length; i++)

{

if(arr[i+1] == arr)

{

result += arr+arr[i+1];

}

if(result > maxResult)

maxResult = result;

}

System.out.println(maxResult);

thanks alot

Abed

[390 byte] By [Abed_Ghamlousha] at [2007-10-2 9:12:37]
# 1
> if(arr[i+1] )What do you think will happen if i is arr.length-1?
CeciNEstPasUnProgrammeura at 2007-7-16 23:19:39 > top of Java-index,Java Essentials,Java Programming...
# 2
Stop the loop one iteration earlier.By the way, both the API description and the error message, as well as the stack trace of an AAIOBE are very obvious and straightforward in pointing out the error's cause.
CeciNEstPasUnProgrammeura at 2007-7-16 23:19:40 > top of Java-index,Java Essentials,Java Programming...
# 3
thx alot, its working :)Abed
Abed_Ghamlousha at 2007-7-16 23:19:40 > top of Java-index,Java Essentials,Java Programming...