Open In App

Scala List isEmpty Operation with example

Last Updated : 13 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads