Re: About Question enthuware.ocpjp.v11.2.1245 :
Posted: Tue Mar 14, 2023 2:26 pm
This alternative is a bit confusing...
"Resources are closed in the reverse order of their declaration in the try clause (or creation, if they are created in the try clause)."
It means: If I create my resources "outside" try-clause, ... are they will be closed in sequential order? Of course, not.
EX: Resources were created "outside" try-clause
ZipFile resource1 = new ZipFile(zipFileName);
BufferedWriter resource2 = Files.newBufferedWriter(path, charset);
try ( resource1;
resource2;
) { ... }
Am I wronged?
"Resources are closed in the reverse order of their declaration in the try clause (or creation, if they are created in the try clause)."
It means: If I create my resources "outside" try-clause, ... are they will be closed in sequential order? Of course, not.
EX: Resources were created "outside" try-clause
ZipFile resource1 = new ZipFile(zipFileName);
BufferedWriter resource2 = Files.newBufferedWriter(path, charset);
try ( resource1;
resource2;
) { ... }
Am I wronged?