"I thought you had already figured out finalize."
"That's what I thought. But now we have this try-with-resources statement."
"Crap. I'm never going to finish learning Java at this rate. I think I understand everything, and then you show up!"
"Don't fret like that—you'll rupture an oil line. Instead, figure out these tasks:"
Refactor the writeZipEntriesToFile method to use the Java 7 try-with-resources construct. The program should not have commented code.
Implement the finalize method after first thinking about what exactly it should contain. Refactor the getUsers method to use the Java 7 try-with-resources construct.
AutoCloseable and try-with-resources
In the FakeConnection class, implement the AutoCloseable interface so that FakeConnection objects can be used in try-with-resources blocks. The close() method should display the phrase "Closing database connection..." In the try block, call the usefulOperation() method and then the unsupportedOpera
GO TO FULL VERSION