발견배열이 필요하지만, java.lang.String의 자바 클래스 배열 오류
array required, but java.lang.String found
을하고 그 이유를 모르겠어요.
내가하려는 것은 객체의 인스턴스를 넣어 (올바른 용어라고 생각합니다.) 객체의 해당 유형의 배열에 넣는 것입니다.
public class Player{
public Player(int i){
//somecodehere
}
}
다음 내 주요 방법 나는 그것의 인스턴스를 생성 :
나는 클래스가
static final Player[] a = new Player[5]; // this is where I'm trying to create the array.
public static void main(String[] args){
Player p = new Player(1);
a[0] = p; //this is the line that throws the error
}
이 왜 어떤 아이디어? 코드에서
예외를 throw하는 코드가 표시되지 않습니다. 이 코드는 괜찮습니다. –
예외가 발생한 코드를 Google에 제공하십시오! – Rugal
그냥 저장하고 다시 컴파일하십시오. –