Log in from a computer to take this course

You'll need to log in from a computer to start Learn Intermediate Java. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

Great job! You’ve learned a lot about serialization.

In this lesson we’ve discussed how:

  • Java make serialization easy using the Serializable interface.
  • The Serializable interface is a marker interface and requires no methods to be implemented.
  • To use FileOutputStream and ObjectOutputStream to serialize objects to a file.
  • To use FileInputStream and ObjectInputStream to deserialize objects from a file.
  • static and transient fields are not serializable.
  • The JVM handles serializing objects with reference type fields.
  • To implement writeObject() to customize the serialization of an object to handle non-serializable fields.
  • To implement readObject() to customize the deserialization of an object with non-serializable fields.

Knowing these topics will improve your mastery of Java and allow you to persist your objects past program termination or transport them over a network.

Instructions

Use Main.java to explore serialization and deserialization by creating new files and classes. Some ideas to explore:

  • Seeing the NotSerializableException
  • Handling transient fields with custom serialization
  • Serializing child classes with non-serializable parent classes

Have fun!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?