ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

CollectionAPI: how to sort derived type elements (set type) other then collections sort method?

user-image
تم إضافة السؤال من قبل vivek vivek
تاريخ النشر: 2013/07/09

your answer is one word "SortedSet" The SortedSet interface extends Set and declares the behavior of a set sorted in ascending order.
In addition to those methods defined by Set, the SortedSet interface declares the methods summarized in below Table: Several methods throw a NoSuchElementException when no items are contained in the invoking set.
A ClassCastException is thrown when an object is incompatible with the elements in a set.
A NullPointerException is thrown if an attempt is made to use a null object and null is not allowed in the set.
example : - public class SortedSetTest { public static void main(String[] args) { // Create the sorted set SortedSet set = new TreeSet(); // Add elements to the set set.add("b"); set.add("c"); set.add("a"); // Iterating over the elements in the set Iterator it = set.iterator(); while (it.hasNext()) { // Get element Object element = it.next(); System.out.println(element.toString()); } } } source: http://www.tutorialspoint.com/java/java_sortedset_interface.htm

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟