나는이 방법으로 프로그램을 만들어야합니다 설정하는 Jugadores에서 주연 :유형의 안전 : 체크되지는 <Jugador>가
private static Set<Jugador>cargarJugadores(String f) throws FileNotFoundException,IOException
{
ObjectInputStream entrada=null;
Set<Jugador>listaDeJugadores=null;
//entrada= new ObjectInputStream(new FileInputStream(f));
try
{
entrada=new ObjectInputStream(new FileInputStream(f));
//Error here
listaDeJugadores=(Set<Jugador>) new Jugadores();
byte numDePuntuaciones;
while(entrada.readObject()!=null)
{
listaDeJugadores.add((Jugador)entrada.readObject());
numDePuntuaciones=entrada.readByte();
for(int i=0;i<numDePuntuaciones;i++)
{
listaDeJugadores.add((Jugador)entrada.readObject());
}
}
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(InvalidClassException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
finally
{
try
{
if(entrada!=null)
entrada.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
return listaDeJugadores;
}
하지만 난이 오류 recived : 나는 시간이하지만 난을 해결하려고했던
Exception in thread "main" java.lang.ClassCastException: Jugadores cannot be cast to java.util.Set at JuegoAsteroides.cargarJugadores(JuegoAsteroides.java:340) at JuegoAsteroides.main(JuegoAsteroides.java:36)
을 그것을 얻지 않았다. 도와주세요. 이
listaDeJugadores=new HashSet<Jugador>();
클래스'Jugadores'는 어디에 있고'Set'을 구현합니까? – RealSkeptic