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 :
Moderator: admin
-
- Posts: 6
- Joined: Sun Feb 07, 2021 9:49 am
- Contact:
-
- Site Admin
- Posts: 10058
- 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!
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 90 guests