import java.io.*; import java.util.*; public class SerializeDemo { public static void main(String [] args) { Employee e = new Employee(); e.name = "Vana Doufexi"; e.address = "Gklavani 37, Volos"; e.AMKA = 11122333; e.salary = 1000.9999; Employee e1 = new Employee(); e1.name = "George Thanos"; e1.address = "28hs Septembriou & Glavani, Volos"; e1.AMKA = 11122999; e1.salary = 458.1234; e.next = e1; e1.next = e; e.list = new ArrayList<>(); e.list.add(e); e.list.add(e1); e1.list = new ArrayList<>(); e1.list.add(e); e1.list.add(e1); try { FileOutputStream fileOut = new FileOutputStream("./employees.ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(e); out.writeObject(e1); out.close(); fileOut.close(); System.out.printf("Serialized data is saved in /tmp/employee.ser"); }catch(IOException ex) { ex.printStackTrace(); } } }