Scala List size() method with example
Last Updated :
26 Jul, 2019
The size() method is utilized to find the number of elements in the stated list.
Method Definition: def size(): Int
Return Type: It returns the number of elements in the stated list.
Example #1:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 1 , 2 , 3 , 4 , 5 )
val result = m 1 .size
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 1 , 0 )
val result = m 1 .size
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...