Hello, I have a question. I am trying to deserialize an object in java, but I am doing the deserialization from an external class to main and when passing it to a sysout, this appears: [LSerializacion.Notes;@58651fd0, any solution? I leave code below
THIS WOULD BE THE CLASS TO SERIALIZE AND DE-SERIALIZE:
// desearilizar
public static Object deserialize(String fileName) throws IOException,
ClassNotFoundException {
FileInputStream fileIN = new FileInputStream(fileName);
ObjectInputStream in = new ObjectInputStream(fileIN);
Object obj = (Object) in.readObject();
in.close();
System.out.println("El objeto ha sido deserealizado");
System.out.println(obj.toString());
return obj;
BELOW I LEAVE THE MAIN:
try (/* VARIABLES */
Scanner sc = new Scanner(System.in)) {
Notas[] notas1dam = new Notas[6];
double[] notasmedias = new double[6];
int contador = 1;
String nombre = "Dario";
/* VARIABLES */
System.out.println("Bienvenido al programa de tus notas. Introduce tus notas porfavor.");
// INGRESAR LAS NOTAS DENTRO DEL ARRAY \ EL NOMBRE DEL ALUMNO LO HE DEFINIDO
// ARRIBA PARA QUE NO ESTÉ PREGUNTANDO EL NOMBRE CADA VEZ Q METES LA NOTA
for (int i = 0; i < notas1dam.length; i++) {
System.out.print("Introduce la nota de la " + contador + "º asignatura ");
double notasalumno = sc.nextInt();
notasmedias[i] = notasalumno;
notas1dam[i] = new Notas(nombre, notasalumno);
contador++;
}
// SERIALIZACION
try {
notasSerializacion.serialize(notas1dam, "hola.ser");
} catch (IOException e) {
e.printStackTrace();
return;
}
// SERIALIZACION
// DESERIALIZACION
try {
notasSerializacion.deserialize("hola.ser");
// printdata(notas1dam);
} catch (IOException e) {
e.printStackTrace();
return;
}
// DESERIALIZACION Y A CONTINUACIÓN SACAMOS LA MEDIA
System.out.println("La nota media del alumno '" + nombre + "' es: " + medianotas(notasmedias));
}