Int) => x + y { int x, int y -> x + y } lambda {|x, y| x + y} lambda x,y: return x * y function (x,y) {return x * y} JavaScript (int x, int y) => x + y C#
widget); ! // Gives compile time error void onDoubleClick(Widget widget); } java: Unexpected @FunctionalInterface annotation lv.jug.java8.Listener is not a functional interface multiple non-overriding abstract methods found in interface lv.jug.java8.Listener
argument • Consumer: An action to be performed with the object passed as argument • Function: Transform a T to a U • Supplier: Provide an instance of a T (such as a factory) • UnaryOperator: A unary operator from T -> T • BinaryOperator: A binary operator from (T, T) -> T
Arrays.sort(array, new Comparator<Integer>() { @Override public int compare(Integer a, Integer b) { return Util.compare(a, b); } }); Arrays.sort(array, Util::compare);
String> one = String::trim; Function<String, String> two = one.andThen( (s) -> s.replaceAll("s", “") ); String result = p.process(two); System.out.println(result);
job” ““This is the first time we have done a carefully coordinated co-evolution of the JVM, the language, and the libraries all together – and the results still feel like Java,”” “Java SE 8 lands with Lambda expressions making coding easier for multi-core processors"