In Scala mutable collections, SortedSet init() method is utilized to find all the elements of the SortedSet except the last one.
Method Definition: def init: SortedSet[A]
Return Type: It returns all the elements of the SortedSet except the last one.
TreeSet(1, 2, 3, 4)
TreeSet(3, 16, 22, 41)
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.