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:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 2 , 5 )
val result = s 1 .size
println(result)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 2 , 10 , 115 , 96 , 36 , 47 , 458 , 21 )
val result = s 1 .size
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...