0
私は速いハングマンゲームを作っていて、IndexOutOfBoundsException
に出くわして、なぜか不思議に思っていました。私は、このエラーがどのように起こるか、問題を見ません。IndexOutOfBoundsエラー、ハングマンゲーム
それは、この行で行わ:
array[index]+=c;
すべてのフィードバックを歓迎です。
import java.io.IOException;
import java.util.Scanner;
public class Driver {
public static void main(String[]args) throws IOException {
Scanner console = new Scanner (System.in);
String[] phrase={"television"};
String[] array= new String[phrase.length];
int body =6;
while(array!=phrase) {
char c=(char)System.in.read();
int index= console.nextInt();
array[index]+=c;
if(array[index].charAt(index)==phrase[index].charAt(index)){
System.out.println("the new array");
}
}
}
}
@Jensそれがここで宣言されます: 'int型のインデックス= console.nextInt (); '、質問は入力が何であるかです。 –
あなたの投稿を編集し、完全なスタックトレースを含めてください。 –
@Ori Lentzどういう意味ですか? –