I have written a code for finding the missing number in series. Here, i am also getting correct result an missing number but with exception. The exception is arrayindexoutofboundsexception which is likely possible because i am increasing the length of array.
Code is below . Any help to remove that exception ...
import java.io.*;
class findarr
{
public static void main(String args[]) throws IOException
{
int a[] = {10,12,14,16,20};
int x,y,z;
for(int i=0;i<a.length;i++)
{
z = a[i+1]-a[i];
if(z!=2)
{
x = a[i]+2;
y = a[i+1]-2;
if(x==y)
System.out.println(x);
}
}
}
}
for(int i=0; i < a.length -1; i++)