Open In App

Scala ListSet isEmpty() method with Example

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 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 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

 


Article Tags :