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#
// Scala program of length() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a list val m1 = List(3, 4, 5, 7, 8) // Applying length method val result = m1.length // Displays output println(result) } } |
chevron_right
filter_none
Output:
5
Example: 2#
// Scala program of length() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a list val m1 = List() // Applying length method val result = m1.length // Displays output println(result) } } |
chevron_right
filter_none
Output:
0
Recommended Posts:
- Scala Iterator length() method with example
- Scala List take() method with example
- Scala List splitAt() method with example
- Scala List drop() method with example
- Scala List takeWhile() method with example
- Scala List takeRight() method with example
- Scala List sum() method with example
- Scala List size() method with example
- Scala List product() method with example
- Scala List min() method with example
- Scala List max() method with example
- Scala List filter() method with example
- Scala List filterNot() method with example
- Scala List addString() method with example
- Scala List addString() method with a separator with example
- Scala List addString() method with a start, a separator and an end with example
- Scala List apply() method with example
- Scala List contains() method with example
- Scala List distinct() method with example
- Scala List dropRight() method with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

