SortedSet

SortedSet

  • It is the child interface set.
  • If we want to represent a group of objects without duplicates, according to some sorting order, then we should go for SortedSet interface.
  • The sorting order can be natural sorting order or customized sorting order.
  • SortedSet defines the following six specific methods.
  1. Object first ();
  2. Object last ();
  3. SortedSet headset (object o ) // returns sortedset, whose elements are less than the specified object.
  4. SortedSet tailset ( object o )//  returns the SortedSet, whose elements are greater than or equal to object.
  5. SortedSet subset ( object 01, object 02 ) ; //  returns the SortedSet, whose elements are greater than or equal to 01 & less than 02.
  6. Comparator comparator () // returns the Comparator object, that describes underlying sorting techniques. If we are depending on natural sorting order, then this method returns null
  • First () → 100
  • Last () → 106
  • Headset ( 103 ) → 100, 101, 102
  • Tailset ( 103 ) → 103,104,105,106
  • Subset ( 100,105 ) → 101,102,103,104
  • Comparator () → null

The Author

Narayanaswamy

Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development. I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.

Leave a Reply