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);};
About Question enthuware.ocpjp.v11.2.1468 :
Moderators: Site Manager, fjwalraven
-
- Posts: 5
- Joined: Sun Feb 07, 2021 9:49 am
- Contact:
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1468 :
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!
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!
Who is online
Users browsing this forum: No registered users and 4 guests