Skip to content
Related Articles

Related Articles

Improve Article
Scala ListSet isEmpty() method with Example
  • Last Updated : 03 Nov, 2019


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