I have started to read about serialization in Java and little bit in other languages too, but what if I have a generic class and I want to save a instance of it to file.
You need to make generic class Serializable
as usual.
public class Generic
If fields are declared using generic types, you may want to specify that they should implement Serializable
.
public class Generic
Please be aware of uncommon Java syntax here.
public class Generic