Collections.sort () mit Komparator? [geschlossen]

import java.util.*;

public class C_2 {
    public static void main(String args[]) {
        String theStrings[] = { "x", "a", "b", "c", "d" };
        List l = Arrays.asList(theStrings);
        Collections.sort(l);                            // line a
        Collections.sort(l, new ThisIsMyThing());       // line b
        System.out.println(l);
    }
}

class ThisIsMyThing implements Comparator {
    public int compare(Object o1, Object o2) {
        String s1 = (String)o1;
        String s2 = (String)o2;

        return -1 * s1.compareTo(s2);
    }
}

Ich verstehe diese KlasseC_2 sortiert nach zwei verschiedenen Techniken. Eins ist der StandardCollections.sort(l); Und der andere istCollections.sort(l,Comparator<>()); Ich kann diese Sortiermethode nicht verstehen. Kann mir das bitte jemand erklären?

Antworten auf die Frage(3)

Ihre Antwort auf die Frage