FAQ: Serialization: Lesson - Serializing Objects to a File

This community-built FAQ covers the “Serializing Objects to a File” exercise from the lesson “Serialization: Lesson”.

Paths and Courses
This exercise can be found in the following Codecademy content:

[BETA] Learn Intermediate Java

FAQs on the exercise Serializing Objects to a File

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

This course is a little rough. (The beginner Java course is much more polished. I didn’t have any problem with anything not working as described.) The article on using the command line where we built the Transportation set of files does not compile as written.

This particular exercise says a cars.txt file will appear but it did not for me. I’m pretty sure I’ve done it correctly.

4 Likes

What I didn’t get is this, will Java create a .txt file with the specified name if no such file exists? Suppose there’s no file named cars.txt. Would this line cause problems during compiling?

FileOutputStream fileOutputStream = new FileOutputStream("cars.txt");

And if FileInputStream/FileOutputStream doesn’t create files, then how do I do it with Java code?

I had the same bug, cars.txt didn’t appeared in the folder. Solved adding the constructor that was missing.

public Car(String make, int year) {
this.make = make;
this.year = year;
}

3 Likes

It’s been a year and this issue still exists. This course definitely needs revisiting and more polishing.

Adding a constructor for the Car class will fix this issue.

1 Like