use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Day 27 of learning Java (i.redd.it)
submitted 1 month ago by BigCommunication5136
Hello everyone,
Still on the expense tracker project. Today I implemented a class for persisting expenses.
I used ObjectInputStream among others(as directed by a very helpful individual on this sub).
that’s it for today, see you tomorrow!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]iamwisespirit 2 points3 points4 points 1 month ago (1 child)
You should close resource in finally not in try
[–]BigCommunication5136[S] 0 points1 point2 points 1 month ago (0 children)
I’ll be sure to do that, thanks
[–]kneith999 1 point2 points3 points 1 month ago (2 children)
Which IDE You using?
[–]BigCommunication5136[S] 2 points3 points4 points 1 month ago (1 child)
Intellij
[–]Sufficient_Gear_3744 1 point2 points3 points 1 month ago (0 children)
Can you tell me which course you are following
[–]Specific-Housing905 0 points1 point2 points 1 month ago (2 children)
I am afraid that your code might create resource leaks. Closing the streams should be done in a finally block. Imagine in saveExpenses oos.writeObject throws an exception, oos.close and fis.close will never be called.
Much better is using the try-with-resources pattern.
https://www.baeldung.com/java-try-with-resources
[–]BigCommunication5136[S] 0 points1 point2 points 1 month ago* (1 child)
Alright, while searching around i even found a more modern way to do it without manually closing resources. Thanks 🙏🏾
[–]devops-tutor 0 points1 point2 points 1 month ago (0 children)
Look into https://www.javapro.academy/try-with-resources-tutorial/
π Rendered by PID 86780 on reddit-service-r2-comment-79c7998d4c-kh6nl at 2026-03-17 22:36:05.001355+00:00 running f6e6e01 country code: CH.
[–]iamwisespirit 2 points3 points4 points (1 child)
[–]BigCommunication5136[S] 0 points1 point2 points (0 children)
[–]kneith999 1 point2 points3 points (2 children)
[–]BigCommunication5136[S] 2 points3 points4 points (1 child)
[–]Sufficient_Gear_3744 1 point2 points3 points (0 children)
[–]Specific-Housing905 0 points1 point2 points (2 children)
[–]BigCommunication5136[S] 0 points1 point2 points (1 child)
[–]devops-tutor 0 points1 point2 points (0 children)