import java.util.ArrayList;Ausgabe:
import java.util.Collections;
import java.util.Hashtabelle;
import java.util.List;
import java.util.Map;
public class TriTreeMap {
public static void main(String[] args) {
//create a hashtable
Hashtableht = new Hashtable ();
//Schlüssel-Wert-Paare hinzufügen
ht.put("d", "vierte");
ht.put("a", "first");
ht.put("c", "dritt");
ht.put("e", "fünfte");
ht.put("b", "sekunde");
System.out.println("Vor dem Sortieren:");
for (Map.Entryentry : ht.entrySet())
{
System.out.println(entry.getKey());
}
//Erstellen einer Arraylist mit den aus hashtable
Listlistcles = new ArrayList (ht.keySet());
//sort arraylist
Collections.sort(listcles);
System.out.println("Nach dem Sortieren:");
for(String key:listcles)
System.out.println(cle);
}
}
Vor dem Sortieren:
b
a
e
d
c
Nach dem Sortieren:
a
b
c
d
e
Please disable your ad blocker and refresh the window to use this website.