I can't understand the method Comparable in Map when I look at the internal interface of Entry < KJI V >.

when you look at the interface of Java"s source code Map, Entry < K _ Magi V >, you can"t understand how to write the methods in it

    public static <K extends Comparable<? super K>, V> Comparator<Map.Entry<K,V>> comparingByKey() {
        return (Comparator<Map.Entry<K, V>> & Serializable)
            (c1, c2) -> c1.getKey().compareTo(c2.getKey());
    }

I can"t understand this writing. Ask for explanation!

Jun.16,2022

(Comparator < Map.Entry < K, V > > & Serializable) means to cast the result to a Comparator object that implements the Serializable interface
this is the syntax of Java8, and means to cast to multiple types

at the same time.

(C1, c2)-> c1.getKey () .compareTo (c2.getKey ()) is equivalent to anonymous inner class:

new Comparator<T>(){
    @Override
    public int compare(T c1, T c2) {
        return c1.getKey().compareTo(c2.getKey());
    }
}

is also the syntax of Java8, Lambda expression

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b40c7c-2c533.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b40c7c-2c533.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?