Skip to content
Related Articles

Related Articles

Scala List isEmpty Operation with example
  • Last Updated : 13 Aug, 2019

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 m1 = List(6, 8, 9, 12)
          
        // Applying isEmpty method
        val result = m1.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 m1 = List()
          
        // Applying isEmpty method
        val result = m1.isEmpty
          
        // Displays output
        println(result)
      
    }
}
Output:
true



My Personal Notes arrow_drop_up
Recommended Articles
Page :