Scala List isEmpty Operation with example
The isEmpty operation is utilized to check if the stated list is empty or not.
Syntax:
m1.isEmpty
Here, m1 is Map name. isEmpty is method which returns true if the stated list is empty else it returns false.
Example #1:
// Scala program of isEmpty() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Creating a list val m 1 = List( 6 , 8 , 9 , 12 ) // Applying isEmpty method val result = m 1 .isEmpty // Displays output println(result) } } |
Output:
false
Example #2:
// Scala program of isEmpty() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Creating a list val m 1 = List() // Applying isEmpty method val result = m 1 .isEmpty // Displays output println(result) } } |
Output:
true
Contact Us