The last option is a bit confusing
Runnable r = ()-> 1+2; would not compile but someMethod() (which returns an int) compiles? How could you explain this?
About Question enthuware.ocpjp.v11.2.3318 :
Moderator: admin
-
- Posts: 10
- Joined: Wed Nov 23, 2022 3:40 am
- Contact:
-
- Site Admin
- Posts: 10064
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3318 :
1+2 is a syntactically illegal statement, while a method call is not.
Please go through this article carefully to understand how a lambda expression is perceived by the compiler:
https://enthuware.com/oca-ocp-java-cert ... interfaces
Please go through this article carefully to understand how a lambda expression is perceived by the compiler:
https://enthuware.com/oca-ocp-java-cert ... interfaces
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 83 guests