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