Hey Cruz, U may have to initialize all the fields at the MyClassToBePersisted.java wz nulls n zeros regards, Heba
--- On Thu, 12/11/08, Cruz Castillo <[email protected]> wrote: From: Cruz Castillo <[email protected]> Subject: [java programming] LAB 1043 - Serializtion To: [email protected] Date: Thursday, December 11, 2008, 5:19 PM Can someone help me, please? I want to finish the homework before December 17, but now, I have a problem with LAB 1043 homework (Serialization). I cannot display the fields of Profile Class and School Class in a serialized file. When run the serialized part, I have the next Exception: ************************************************************************************* Exception in thread "main" java.lang.NullPointerException at SerializeMyClassToBePersisted.main(SerializeMyClassToBePersisted.java:32) Java Result: 1 ************************************************************************************* I did the next: 1.- Write MyClassToBePersisted.java con serialized clause and default constructor. - Profile profile; - School school; - Class Profile with fields and getters and setters - Class School wit fields and getters and setters. 2.- Write SerializeMyClassToBePersisted.java this data: MyClassToBePersisted myFields = new MyClassToBePersisted(); myFields.profile.name = "name1"; myFields.profile.age = 10; myFields.profile.hobby = "hobby1"; myFields.school.nameOfSchool = "name College"; myFields.school.yearStarted = 2000; The line where is the Exception is the first of the previous block: myFields.profile.name = "name1"; ---à here is the Exception 3.- Write the DeserializeMyClassToBePersisted.java Would you give advice to solve the problem. Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
