Loading topic
finally block.2 min readIllegalArgumentException and IOException. Sometimes none of them describes your problem well. You can then write your own exception class. A custom exception is a class you write that extends one of Java's exception classes.2 min readclose() method.2 min readfinally block. That works, but Java needs a way to know that an object can be closed. Two interfaces do that job: AutoCloseable and Closeable.2 min readfinally block works, but it takes a lot of code and is easy to 2 min readtry block throws an exception, and then close() throws one too? Java has to report one of them. This chapter shows how Java keeps both.2 min readtry. Sometimes you already have the resource in a variable. Maybe another line of code created it, or a method gave it to you. Since Java 9, you can put that existing variable straight2 min read