Page 1 of 1

About Question enthuware.ocpjp.v11.2.3419 :

Posted: Wed Dec 29, 2021 4:18 am
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;
	}

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

Posted: Wed Dec 29, 2021 11:01 am
by admin
No, why do you think so? There is a return statement inside the for loop.

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

Posted: Sat Jan 01, 2022 2:11 am
by yuir12
oh ok got it. thanks!