import java.io.*; static class Example implements Serializable { String s = "Hello World!"; private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException { out.defaultWriteObject(); } }