0
About Java course, File reading and writing
In the java course, we can learn to read a file using a File and a Scanner objects. For writing a file, we learn to use a formatter. Why that ? Why not present the "try-with-resources" ? This functionality can be used to write or read a file, and ensuring that the file is closed at the end. https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html https://www.baeldung.com/java-try-with-resources
1 Réponse
+ 2
I honestly don't know why they didn't present try with resources. It's really good to know that there's a way to close the file automatically rather than manually. Again sololearn only teaches the absolute minimum if you really want to fully grasp the concepts you have to dig deeper. Good question tho.