"Protocols in Swift" was retired on May 31, 2020.

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

Lucas Frixione
Lucas Frixione
1,332 Points

there is a bunch of things in the video that were barely explained, Streams, try-catch etc

I seriously tried to understand what he was doing when he created the Treets.java file, but i could not follow anything he did, and i don't want to learn it from memory i want to understand. this is what i understand: FileOutputStream("treets.ser") creates a file where we will store the treets, the .ser i have no idea what it stands for. and that's about it.

what i don't understand:

1) He says streams like we know what it means, it has never been explained for what i remember

2)

ObjectOutputStream  oos = new ObjectOutputStream(fos);

3) any of the catch thingys he did there,

4) why he starts the load() method with

Treet[] treets = new Treet[0];

This pisses me off a little bit because i'm paying quite a lot of money for this courses and this one is just a "copy what i type and google what it means" and according to the comments i'm not the only one who thinks this, i really hope the quality of the videos get better from now on, i'll memorize this for the next time i need it, but i have certaintly not learnt anything from watching the video

Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

Sorry Lucas, but I am not advanced enough in Java to answer this question. Hope you find your answer!

Benyam Ephrem
Benyam Ephrem
16,505 Points

Yeah, I feel you, just rewind and really listen to what he is saying. He perfectly explains it, it's just that it is a "different" idea requiring more thought to really grasp. Simply, FileOutputStream/FileInputStream provides you the level of abstraction where it doesn't matter how it works as long as it turns the object into a saveable binary file that can be loaded later.

2 Answers

Tyler Combs
Tyler Combs
15,525 Points

Just a disclaimer from a fellow student; I'm not sure which plan you're paying for, but I assume it's not the basic plan. That being said, you're not paying $200+ for the videos. $30/month pays for the videos. The value in paying more than that lies in the portfolio you are building, and the certification after completion of the curriculum.

Aside from that, you don't really need to know what a "stream" is; that's not important. But just imagine it like you have a literal stream, like a river, where your data "flows" in and out of the program. An ObjectOutputStream is just used to output data.

Catch blocks are simply used to catch exceptions that are thrown. Input/output streams throw IOExceptions, so you need to catch them.

And finally within the load() method, you're just creating a new empty treet array to be filled later.

I hope this helps! One of my biggest problems is over-thinking things. Most of the time if things start to seem too complicated, you may be over-thinking it. It happens to me all the time. Good luck, let me know if you have any more questions.

Edit: ".ser" is short for serialized.

Lakshmi Narayana Dasari
Lakshmi Narayana Dasari
1,185 Points

@Tyler Combs you should also aware that 200$/month when you are aware of 30$/month. people pay more to get detailed understanding of the concepts. if someone wants a certificate then they can first complete all the classes and just pay 200$ for a month and get certified. Thats an easy wayand would save every one loads of money.I dont know whether you are being biased but when its not important to know about stream why did the instructor use that in the video.Certainly everyone wants to know everything and understand everything.

Tyler Combs
Tyler Combs
15,525 Points

Lakshmi Narayana Dasari That's not possible, they have safeguards in place to prevent that.

What I meant about the stream, is that you don't have to know the definition of it, you just need to understand how it works so that you know how to use it and why you're using it.

Roman Mayer
Roman Mayer
10,925 Points

@Lakshmi: In the Techdegree, you can only submit 1 project per week, so the bare minimum for a certificate is 3 months.

Roman Mayer
Roman Mayer
10,925 Points

Tyler explained the important things.

Actually, Craig Dennis gave a high-level explanation for streams in the video. A FileOutputStream opens (creates if not already exists) a file that your program can write to. An ObjectOutputStream converts you object (and all classes connected to the object) into bytecode that can be written to a file. ObjectOutputStream.writeObject(Object obj) actually writes it to the file.

"The default serialization mechanism for an object writes the class of the object, the class signature, and the values of all non-transient and non-static fields. References to other objects (except in transient or static fields) cause those objects to be written also. Multiple references to a single object are encoded using a reference sharing mechanism so that graphs of objects can be restored to the same shape as when the original was written."

https://docs.oracle.com/javase/7/docs/api/java/io/ObjectOutputStream.html