Exception in thread "main" 에러질문

sanghoon Reply 8 years 31 weeks ago
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x[] = {input.nextInt()}; int y = (x[0]*1+x[1]*2+x[2]*3+x[3]*4+x[4]*5+x[5]*6+x[6]*7+x[7]*8+x[8]*9)%11; if(y==10){ System.out.println(x+"x"); } if(y!=10){ System.out.println(x+""+y); } } } 여기다가 수를 대입하면 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at Main.main(Main.java:8) 라고뜨는데 이게 뭐예요?
withcs1 Reply 8 years 31 weeks ago
8번째 줄에서 배열의 정해진 index를 벗어 났다는 이야기 입니다. ex) int [] a = new int [8]; 에서 a[8]을 사용