Scala SortedSet count() method with example
Last Updated :
02 Nov, 2019
The 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.immutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 1 , 2 , 3 , 4 , 5 )
val result = s 1 .count(z => true )
println(result)
}
}
|
Example #2:
import scala.collection.immutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 7 , 6 , 4 )
val result = s 1 .count(z => true )
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...