Page 1 of 1

About Question enthuware.ocpjp.v11.2.1468 :

Posted: Fri Apr 23, 2021 11:39 am
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);};

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

Posted: Sat Apr 24, 2021 6:25 am
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!