About Question enthuware.ocpjp.v11.2.1468 :

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

Moderator: admin

Post Reply
jeroenisanders
Posts: 6
Joined: Sun Feb 07, 2021 9:49 am
Contact:

About Question enthuware.ocpjp.v11.2.1468 :

Post by jeroenisanders »

Answer 3. I think with an extra semicolumn, t still compiles without a problem
Examples:
Function<String, String> func = (String a) -> a+1;;
BiConsumer<String, String> hConsumer = (String a, String b) -> {System.out.println(a+b);};

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

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

Post by admin »

Actually, the explanation is about a lambda expression as an argument to a method.
Extra semicolons for Java statements are always valid. But a lambda expression passed as an argument is not a statement. It is just an expression and extra semicolon are not permitted there.
The explanation has now been updated to make this point clear.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 41 guests