For this homework, I created MyClassToBePersisted, Profile and School
classes, with each of them implementing Serializable.
Profile class looks like this:
public class Profile implements Serializable{
private String name;
private int age;
private String hobby;
public Profile(String name, int age, String hobby){
this.name = name;
this.age = age;
this.hobby = hobby;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}...
When I run the SerializeMyClassToBePersisted class, I keep getting the
following error: java.io.NotSerializableException: Profile.
SerializeMyClassToBePersisted looks like this:
public class SerializeMyClassToBePersisted {
public static void main(String[] args) {
MyClassToBePersisted persistantClass = new MyClassToBePersisted
();
// Serialize 'persistantClass' object
FileOutputStream fos = null;
ObjectOutputStream out = null;
try {
fos = new FileOutputStream("gino_serializedfile");
out = new ObjectOutputStream(fos);
out.writeObject(persistantClass);
out.close();
} catch(IOException ex) {
ex.printStackTrace();
}...
Can anyone shed any light on the error message?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---