Open In App

Scala ListSet isEmpty() method with Example

Last Updated : 13 Feb, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In Scala ListSet, isEmpty() method is utilized to check if the listSet is empty or not.If it is empty it will return true, else false. 

Method Definition: defisEmpty: Boolean
Return Type: true if the list set contains no elements, false otherwise. 
 

Example 1:  

Scala




// Scala program of isEmpty()
// method
import scala.collection.immutable._
// Creating object
object GfG
{
 
    // Main method
    def main(args:Array[String])
    {
     
        // Creating listset
        val m1 = ListSet(1, 2, 3, 4, 5, 7)
         
        // Applying filter method
        val result = m1.isEmpty
         
        // Displays output
        println(result)
     
    }
}


Output: 

false

 

Example 2: 

Scala




// Scala program of count()
// method
import scala.collection.immutable._
// Creating object
object GfG
{
 
    // Main method
    def main(args:Array[String])
    {
     
        // Creating listset
        val m1 = ListSet()
         
        // Applying filter 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