import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.map;
الطبقة العامة TriTreeMap {
الفراغ العام الثابت الرئيسي (سلسلة [] args) {
// إنشاء hashtable
Hashtableht = جديد Hashtable ();
//add key-value pairs
ht.put("d"، "الرابع")؛
ht.put("a"، "الأول")؛
ht.put ("c" ، "الثالث") ؛
ht.put("e"، "الخامس")؛
ht.put ("b" ، "second") ؛
System.out.println("قبل الفرز:");
ل (Map.Entryإدخال: ht.entrySet())
{
System.out.println(entry.getKey());
}
//إنشاء قائمة صفيف باستخدام المفاتيح المستردة من hashtable
Listlistcles = ArrayList (ht.keySet ()) ؛
//sortarraylist
Collections.sort (listcles) ؛
System.out.println ("بعد الفرز:") ؛
ل (مفتاح السلسلة: listcles)
System.out.println (cle) ؛
} < br / >}
< / string >< / string >< / string >< / string >< / string >< / pre> الإخراج:
< pre class = "prettyprint lang-java" > قبل الفرز:
b
a
e
d
c
بعد الفرز:
أ < ب / > ب < ب / >ج< ب / >د< ب / >ه < / ما قبل >< / ديف>
Please disable your ad blocker and refresh the window to use this website.