Determining Return Type Using Bitwise Operation

I was wandering through the java docs and suddenly I found this code:

public static <T, U extends Comparable<? super U>> Comparator<T> comparing(
        Function<? super T, ? extends U> keyExtractor)
{
    Objects.requireNonNull(keyExtractor);
    return (Comparator<T> & Serializable)
        (c1, c2) -> keyExtractor.apply(c1).compareTo(keyExtractor.apply(c2));
}

      

Can someone explain what magic happens after the return statement ? Okay, the result of a method is defined by a lambda expression combined with a functional interface. But what is it written before? Is this a cast return type via bitwise control? I do not understand. As far as I know, bitwise only applies to numbers. Where can I read more about this case?

+3


source to share


1 answer


Java 8 adds the ability to cast lambda into anonymous intersection. The return type is Comparator<T>

andSerializable

Posted: Answer here



Documentation

Note: Java sometimes adds new syntactic meanings to operators to maintain backward compatibility.

+2


source







All Articles