About Question enthuware.ocpjp.v11.2.1468 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
jeroenisanders
Posts: 5
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: 10384
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!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests