I have heard that Lambda is coming to you for a Java (J8) soon. I have found an example of what they would look like on some blogs:
soccer service soccer service = (Team A, Team B) - & gt; {Soccer Results Results = Faucet; If (Team A == Team B) {Results = SoccerSalt. Draw; } And if (Team A Lieutenant; Team B) {Results = SoccerSult.Lost; } And {Results = Socceras. WON; } Return results; }; So right from the bat:
-
Team A and teamB are typed? Or are they not (like some strange form of generic)? - Is lambda a type to stop, or is it another way?
- What will it profit me on a specific anonymous function?
The lambda expression is a syntax for implementing just one target interface, this means that you have a lambda expression The medium will be implementing a special method in the interface. The compiler can guess the type of parameters in the interface and therefore you do not need to define them clearly in the lambda expression. For example:
Comparator & lt; String & gt; C = (S1, S2) - & gt; S1.compareToIgnoreCase (s2); In this expression, Lambda expression explicitly implements the Comparator of a string, so it means the syntax to compare the Lambda expression to the Chinese (string), string) . In this way, the compiler is safely s1 and s2 is string . Your goal interface type provides all the information, the compiler needs to determine what the actual types of lambda parameters are.
In the Brayrete Goetz, Oracle Coreporten, the Java language architect has published some articles of work in progress in JDK 8 Lambda, I believe that the answers to your questions are here:
- .
-
-
This second article explains how the Lambda expression is implemented at the bytecode level and you can help in the description of your second question. can do.
Comments
Post a Comment