Kombinierte Lambda in Java
Dieses Beispiel zeigt, wie man zwei oder mehrere Lambda Expressions miteinander kombinieren kann. Dazu führt man das erste Lambda addlambda aus und übergibt zugleich das Ergebnis des ersten Lambda als Eingabeparameter für den zweiten Lambda lambdaprinter.
public class CustomLambda {
/* Interface for custom lambda definition */
@FunctionalInterface
public interface Printable<T> {
void print(T toPrint);
}
/* Another interface to add two numbers */
@FunctionalInterface
public interface Addable<T extends Number, R extends Number, S extends Number> {
S sum(T one, R two);
}
public static void main(String[] args){
int x = 7;
short y = 3;
// Declare the new interface for the purpose to sum up a list
Addable<Integer, Short, Integer> addLambda = (a,b) -> a+b;
// Declare the lambda expression
Printable<Integer> lambdaprinter = s -> System.out.println(s);
// Combine lambda with 2 Functional Interfaces
// Result from first lambda is the parameter of the second lambda
lambdaprinter.print(addLambda.sum(x, y));
}
}
0
0
0.000
Bei Java hats bei mir immer aufgehört.
!BBH !PIZZA !PGM
BUY AND STAKE THE PGM TO SEND A LOT OF TOKENS!
The tokens that the command sends are: 0.1 PGM-0.1 LVL-0.1 THGAMING-0.05 DEC-15 SBT-1 STARBITS-[0.00000001 BTC (SWAP.BTC) only if you have 2500 PGM in stake or more ]
5000 PGM IN STAKE = 2x rewards!
Discord
Support the curation account @ pgm-curator with a delegation 10 HP - 50 HP - 100 HP - 500 HP - 1000 HP
Get potential votes from @ pgm-curator by paying in PGM, here is a guide
I'm a bot, if you want a hand ask @ zottone444
@ozelot47! Your Content Is Awesome so I just sent 1 $BBH (Bitcoin Backed Hive) to your account on behalf of @dotwin1981. (11/50)
$PIZZA slices delivered:
@dotwin1981(6/15) tipped @ozelot47