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 trialmohamadreza azadi
5,167 Pointswhat's the serializationUID
hey guys i understood in this video at 13:2:))) after that i dont know what happen and what's that number for seralize our class can anyone help me ?
1 Answer
Rana Melissa Baghdar
9,425 PointsHi!
You have serialize your code after you have returned your class to the normal state. The program's called serialver and your give it the name of the class. And what this'll do is it will generate code that you need to put in your Java class.
In the console you have to write: serialver com.teamtreehouse.Treet (this only works if you have done it the same way as done in the tutorial)
Then you just have to copy the result starting with private and ending with L;, paste this into your
And what this'll do is it will generate code that you need to put into your public class Treet!
Hope this works! Also, read though the teacher's notes and you can see that he did the same thing!
Rares Conea
Courses Plus Student 15,000 PointsRares Conea
Courses Plus Student 15,000 PointsserializationUID is an variable that helps us to make sure that when we try to load some data that we saved earlier we don t get an InvalidClassException.As you saw in the video when we saved the data without having an serializationUID an tried to restore it without making any changes to the class the try was successful because our serializationUID was calculated at runtime considering everything in the class of the object we were trying to save.When we made changes in our code and added a field then our serializationUID changed because the calculation was made cosidering also the new declared field and that s why we got an exception.When we declared the serializationUID in our code then the calculation will no loger be needed, it wil reman the same as we set no matter how many times we run the code or change anything in the class.