Labdas in Java 8 - do you like the syntax?

I just read an overview of the most promising feature of Java 8 and did not like the syntax at all. First of all - the return is sometimes necessary and sometimes not:

Comparator<Integer> cmp = (x, y) -> (x < y) ? -1 : ((x > y) ? 1 : 0);
Comparator<Integer> cmp = (x, y) -> {
  return (x < y) ? -1 : ((x > y) ? 1 : 0);

This looks similar to Scala convention, but less consistent: in Scala block is an object indeed, and the block returns a value, and the value of the block is the value of the last statement, etc. In Java 8, however, these 2 forms look like an exception to the common rules: when you write lambda you can either provide an expression or a block, but in other constructs you cannot interchange between the two.

And what about this C++ syntax of referencing a class method:


Is this allowed everywhere, or, again, only for closures?

I hope the syntax will be consistant in the language, when Java 8 is released, but there is no time left, what do you guys think about it?

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at