Code refuses to compile when using comparator with lambda

Mrityunjay Sharma mrityunjay2002 at gmail.com
Tue Mar 19 11:23:08 PDT 2013


Hi All,
The below code refuses to compile when using comparator.

*shapes1.sort(Comparators.comparing(Shape::getSize));*
*
*
but when i provide the type implementation (as below) of above lambda
expression, it works properly.

               *shapes1.sort(Comparators.comparing(*
* new ToIntFunction<Shape>() {*
* public int applyAsInt(Shape s) {*
* return s.getSize();*
* }}*
* ));*

Please let me know if i am missing something.

Regards,
MJ


More information about the lambda-dev mailing list