About Question enthuware.ocpjp.v11.2.1245 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
edufin166@yahoo.com
Posts: 24
Joined: Wed Sep 28, 2022 9:41 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.1245 :

Post by edufin166@yahoo.com »

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?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v11.2.1245 :

Post by admin »

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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 27 guests