The toList() method is utilized to return a list consisting of all the elements of the TreeSet.
Method Definition: def toList: List[A]
Return Type: It returns a list consisting of all the elements of the TreeSet.
TreeSet(1, 2, 3, 4, 5) Elements in the list: 1 2 3 4 5
TreeSet(a, e, i, o, u) Elements in the list: a e i o u
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.