Java TreeSet comparator() MethodThe comparator() method of TreeSet class returns the comparator used for sorting the elements. If the comparator uses natural ordering for sorting, it returns null Specified bycomparator in interface SortedSet<E> : it returns the comparator used for sorting the elements. If the comparator uses natural ordering for sorting, it returns null Return:It returns the comparator used for sorting the elements. It returns null in the case of natural ordering. Example 1Output: TreeSet: null Example 2Output: TreeSet: [A, B, a, b] Next TopicJava-treeset-first-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India