Check out example codes for "objectoutputstream exemple". It will help you in understanding the concepts better.

Code Example 1

public static void main(String[] args) throws IOException, ClassNotFoundException {
  Obj array[] = new Obj[10];
  for (int i = 0; i < array.length; i++) {
    array[i] = new Emp(i);
  }
  try {
    ObjectOutputStream fOUT = new ObjectOutputStream(new FileOutputStream("prodotti.dat"));
    for (int i = 0; i < array.length; i++) {
      fOUT.writeObject(array[i]);
    }
    fOUT.close();
  } catch (IOException e) {
    System.out.println("Errore nella scrittura");
  }
  ObjectInputStream fIN = new ObjectInputStream(new FileInputStream("prodotti.dat"));
  while (true) {
    try {
      Obj p = (Obj) fIN.readObject();
      System.out.println(Obj.method());
    } catch (EOFException e) {
      break;
    }
  }
}

Learn ReactJs, React Native from akashmittal.com