我正在尝试解决一个程序,一次又一次发生异常我不知道为什么在这里帮助我是我的代码
import java.util.*;
public class Fashion
{
public static void main(String args[])
{
int sum=0;
Scanner in=new Scanner(System.in);
System.out.println("enter the number of judges");
int x=in.nextInt();
int a[]=new int[x];
if((x<20)&&(x%2==1))
{
System.out.println("score given by judges");
for(int i=0;i<x;i++)
{
a[i]=in.nextInt();
}
}
int mid=(1+x)/2;
for(int k=0;k<mid;k++)
{
if(a[mid+k]==a[mid-k]) //exception here why
{
sum=sum+a[mid+k];
}
}
System.out.println("the number get by the contestant is "+sum);
}
}