私はJavaを始めたばかりで、なぜこのコードなのか理解できません:
char WORDS[][] = {"jazz", "buzz", "hajj", "fuzz", "jinx", "jazzy", "fuzzy", "faffs", "fizzy", "jiffs", "jazzed", "buzzed", "jazzes", "faffed", "fizzed", "jazzing", "buzzing", "jazzier", "faffing", "fuzzing"};
char comp[] = WORDS[rand.nextInt(WORDS.length)];
char compHidden[comp.length];
次のエラーが発生します。
- Syntax error on token "[", = expected
- Type mismatch: cannot convert from int
to char
- Syntax error on token "]", delete this
token
すべて 3 行目にあります。どうしてこれなの?char 配列の長さを調べる別の方法はありますか?