Skip to content
Related Articles

Related Articles

Improve Article

Scala Mutable SortedSet size() method

  • Last Updated : 26 Mar, 2020

In Scala mutable collections, SortedSet size() method is utilized to find the number of elements in the SortedSet.

Method Definition: def size: Int

Return Type: It returns the number of elements in the SortedSet.

Example #1:




// Scala program of size() 
// method 
import scala.collection.mutable.SortedSet
  
// Creating object 
object GfG 
  
    // Main method 
    def main(args:Array[String]) 
    
        // Creating a SortedSet 
        val s1 = SortedSet(2, 5
          
        // Applying size method 
        val result = s1.size
          
        // Display output
        println(result)
    
Output:
2

Example #2:




// Scala program of size() 
// method 
import scala.collection.mutable.SortedSet
  
// Creating object 
object GfG 
  
    // Main method 
    def main(args:Array[String]) 
    
        // Creating a SortedSet 
        val s1 = SortedSet(2, 10, 115, 96, 36, 47, 458, 21
          
        // Applying size method 
        val result = s1.size
          
        // Display output
        println(result)
    
Output:
8



My Personal Notes arrow_drop_up
Recommended Articles
Page :