//there is problem with this code, I can not fix it. //can someone please help to explain it? Thanks!! import java.io.*; public class TransientWriter implements Externalizable {
private transient String s = "Hope I can ever be persistant!"; public void writeExternal(ObjectOutput oOut) throws IOException { oOut.writeObject(s); }
You didn't say what your problem is but, you need to read the JLS on the use of the transient keyword. It prevents that data from being written to the object output stream! Change your code to this and rerun it.
Use Serializable not Externalizable. see below. import java.io.*; public class TransientWriter implements Serializable // not Externalizable { private transient String s = "Hope I can ever be persistant!";