Java - newgeekorder/TechWiki GitHub Wiki
== Java 8 - Lamdas ==
Lambdas are compact single method classes that represent behavior. They can either be assigned to a variable or passed around to other methods just like we pass data as arguments.
// Concatenating strings
(String s1, String s2) -> s1+s2;
// Squaring up two integers
(i1, i2) -> i1*i2;
// Summing up the trades quantity
(Trade t1, Trade t2) -> {
t1.setQuantity(t1.getQuantity() + t2.getQuantity());
return t1;
};
// Expecting no arguments and invoking another method
() -> doSomething();