Skip to content
Related Articles

Related Articles

Scala ListSet isEmpty() method with Example

View Discussion
Improve Article
Save Article
  • Last Updated : 27 Dec, 2021
View Discussion
Improve Article
Save Article

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 litset
        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 litset
        val m1 = ListSet()
         
        // Applying filter method
        val result = m1.isEmpty
         
        // Displays output
        println(result)
     
    }
}

Output: 

true

 


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!