About Question enthuware.ocpjp.v11.2.3419 :

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

Moderator: admin

Post Reply
yuir12
Posts: 22
Joined: Thu Dec 09, 2021 11:23 pm
Contact:

About Question enthuware.ocpjp.v11.2.3419 :

Post by yuir12 »

Hello, just a question:

does this not suggest infinite loop? tia

Code: Select all

	public long getTotal(String file) throws IOException {
		long sum = readFileBuffered(file, (InputStream in) -> {
			long current = 0;
			for (;;) {
				int b = in.read();
				if (b == -1) {
					return current;
				}
				current += b;
			}
		});
		return sum;
	}
Last edited by admin on Wed Dec 29, 2021 10:59 am, edited 1 time in total.
Reason: wrapped code within [code] [/code] and formatted

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

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

Post by admin »

No, why do you think so? There is a return statement inside the for loop.
If you like our products and services, please help us by posting your review here.

yuir12
Posts: 22
Joined: Thu Dec 09, 2021 11:23 pm
Contact:

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

Post by yuir12 »

oh ok got it. thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 63 guests