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?
About Question enthuware.ocpjp.v11.2.1245 :
Moderator: admin
-
- Posts: 24
- Joined: Wed Sep 28, 2022 9:41 am
- Contact:
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1245 :
Please read the statement carefully:
Resources are closed in the reverse order of their declaration in the try clause. That is what is happening in your example, right?
The part in parentheses is about the case when resources are created (instead of just declared) in try clause.
Resources are closed in the reverse order of their declaration in the try clause. That is what is happening in your example, right?
The part in parentheses is about the case when resources are created (instead of just declared) in try clause.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: rwilliams93 and 89 guests