배열 오류가 발생하여 범위를 벗어났습니다. 무엇이 잘못되었는지는 알 수 없습니다.문자열 배열 오류
import java.util.*;
public class gameVar {
public static int size;
public static int counter;
public static Scanner input = new Scanner(System.in);
public static String currentIn;
public static String nameArray[] = new String[size];
}
와 (전 6 행에 오류를 얻고있다) 두 번째 클래스는 : 여기 내 코드는
은public class mainThread extends gameVar {
public static void main(String[] args){
System.out.println("Please type the desired amount of players: ");
size = input.nextInt();
for(int counter = 0; counter < size; counter++){
System.out.println("Please enter the name of player " + nameArray[counter])
}
}
}
는 당신의 도움이 많이 감사합니다!
당신은'nameArray [counter]'가 루프의'counter'의 모든 값에 유효한 값입니까? – Aiias