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

Serialization - Clarification on "Sequence of Bytes"

When we serialzie thigns, we convert the object to a sequence of btes so that it can be easily be stored in a storage.

Two questions:

  1. By transforming it to a sequence of btes, does it mean something like this?:

An object's size is 1kb, we turn it into a sequence of bytes, so now it's 1000 bytes. This way this can be easily stored.

(Curiosity question)2.Why must we transform it into a sequence of bytes? does the compiler find it easier to process or some sort?

1 Answer

If you want to get more on bytes, there is a nice 'computer basics' course:

https://teamtreehouse.com/library/computer-basics/computer-basics/binary

"An object's size is 1kb, we turn it into a sequence of bytes, so now it's 1000 bytes." - this is not right. When we convert something in bytes, we "change the object representation to zeroes and ones" very very roughly saying.

Byte language is the language machines speak ,so of course it would be faster if we convert object to bytes.

I didn't take that course yet- but will certainly do to refresh memory.

I also wanted to add about storage in text versus storage in bytes:

" For example, suppose you wanted to write the number 100000. If you type it in ASCII, this would take 6 characters (which is 6 bytes). However, if you represent it as unsigned binary, you can write it out using 4 bytes."

https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/asciiBin.html