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 Java Data Structures - Retired Organizing Data Serialization

Meirambek Tungatarov
Meirambek Tungatarov
5,889 Points

Can anyone help me ? How did Treets.read(); method find out what file to read/disserialize ?

1st question: in Example class Treets.read(); method how did it figure out what file to read , if Craig didn't pass any parameters ? 2nd one : in Treets class in the load method Craig downcasted the returned by readObject data .How readObject knew what object(array of treets of type Treet) to return , if there was no argument/parameter passed in ? I need your answers !

1 Answer

1- Okay, so the command was: Treets.save(); going to the Treets class we have a method named save which needs nothing passed into. its like the Interger.parseInt(<STRING>) thing, it refers to the class itself and not a specific object, in the parseInt example it takes a String and returns an int, but i hope you get the idea, it's basically calling a method which is inside another class. 2- About this question Im kind of struggling myself, hopefully someone could answer us both.