Start learning now
You've reached Level 20!
Congratulations, you've completed Level 9 of the quest! You've learned a lot about I/O streams, gotten acquainted with adapters, practiced writing your own wrappers for System.out, and completed 29 tasks (unless you left two or three for later). On Level 10, we'll study serialization.
Saving an Object array
Your attention, please! At the secret CodeGym center, today there is a seminar named "How to Save an Object in a File One Line at a Time". All students who have reached the tenth level of the second quest are invited to attend. The seminar will be taught by Eleanor Carrey, doctor of interstellar sciences and our ship's navigator.
Saving an Object array to a file
Your teacher Diego has heard rumors that you, along with the other students on this level, attended a very interesting seminar that taught you how to save an object to a file one line at a time. Diego can't let that be. Now you'll have to complete tasks on this topic. But you wouldn't have it any other way, right?
Serialization. The beginning.
The Java machine can store and load its objects. It doesn't even need save and load methods to do it: All objects are stored inside the Java machine, and it has full access to them. Thus, serialization is the process of storing object state in a sequence of bytes, and it's native to the Java machin
Practice with serialization
How do you serialize a person? How do you serialize CodeGym? How do you serialize a singleton? How do you serialize static fields? Finally, how do you serialize something of your own? You'll have to answer these questions today by completing 5 tasks about serialization, prepared for you by Diego.
Class properties marked with the transient modifier are not serialized. Such fields usually store intermediate object state that may be easier to calculate than to serialize and then deserialize. Why? You'll learn in the lesson.
Java has a very useful Externalizable interface. If it is replaced by the Serializable interface, a class can manage the serialization process manually. All because the Externalizable interface has two methods (which the Serializable interface does not) that are called by the Java machine when an object is serialized. Your teacher Rishi will show you what this looks like.
Tasks about serialization and deserialization
Serialization isn't so simple, is it? However, it's entirely within the reach of students wrapping up the second quest. Your teacher Diego invites you to reach it with some practice right now. That's why he's prepared five interesting tasks (or not so interesting, depending on who you ask).
Useful links from the Professor — 20
Of course, looking at the same material from different angles is useful, because everyone thinks differently, and perhaps for you the best source of the theory will be different from the source best suited to your friend. Today Professor Noodles has found you an interesting article on serialization.
How computer memory works
Are you ready to finish this quest? You might need a short breather before the final leap. We have a cool video today. This short but detailed explanation will teach you how computer memory works. And, of course, you’ll receive some dark matter. Good luck in completing the final tasks! But for now, relax and hit the play button.
Bonus task | Lesson 10 | Level 10
Captain Squirrels is on the phone! He has a couple of surprises for you. More precisely, not a couple, and they aren't surprises, but rather ten tasks on serialization. Consider them (and the three bonus tasks on algorithms) the final test of the quest.