implements Serializable
/* */ import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class MainClass { public static void main(String[] args) { Employee e = new Employee(); e.name = "Jor Lee"; e.address = "USA"; e.SSN = 11122333; e.number = 101; try { FileOutputStream fileOut = new FileOutputStream("employee.ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(e); out.close(); fileOut.close(); } catch (IOException i) { i.printStackTrace(); } } } class Employee implements java.io.Serializable { public String name; public String address; public transient int SSN; public int number; public void mailCheck() { System.out.println("Mailing a check to " + name + " " + address); } }