Scala Mutable SortedSet count() method
In Scala mutable collections, count() method is utilized to count the number of elements in the SortedSet.
Method Definition: def count(p: (A) => Boolean): Int
Return Type: It returns the number of elements present in the SortedSet.
Example #1:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 10 , 22 , 32 , 4 , 5 )
val result = s 1 .count(z => true )
println(result)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 72 , 666 , 454 )
val result = s 1 .count(z => true )
println(result)
}
}
|
Last Updated :
26 Mar, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...