草庐IT

Closable

全部标签

java - 在 Closable.close() 中抛出运行时异常

在我学习OCPJP8的过程中,我遇到了一个问题,但我并没有很明确的答案。考虑以下代码:publicclassAnimals{classLambimplementsCloseable{publicvoidclose(){thrownewRuntimeException("a");}}publicstaticvoidmain(String[]args){newAnimals().run();}publicvoidrun(){try(Lambl=newLamb();){thrownewIOException();}catch(Exceptione){thrownewRuntimeExcept