Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Javique Ryan
PLUS
Javique Ryan
Courses Plus Student 2,405 Points

Serialization in Java

Why do i need to serialize my objects in java programming? Is Serialization the only way to save objects?

1 Answer

Serialization lets us read/write objects from/to a file. You need to serialize an object to be able to write it to a file, and you have to deserialize an object to be able to read it from a file. After you write a serialized object into a file, you can read it by deserializing it; then the type information and bytes that represent the object and its data can be used to recreate the object in memory. That let's us serialize on one platform and deserialize on another entirely different platform, since it's JVM independent.

About alternatives to serialization, I think this could help you: https://stackoverflow.com/questions/239280/which-is-the-best-alternative-for-java-serialization