📜  带有示例的 Scala ListSet isEmpty() 方法

📅  最后修改于: 2022-05-13 01:54:27.781000             🧑  作者: Mango

带有示例的 Scala ListSet isEmpty() 方法

在 Scala ListSet 中,isEmpty() 方法用于检查 listSet 是否为空,如果为空则返回 true,否则返回 false。

示例 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)
     
    }
}


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


输出:
false

示例 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)
     
    }
}
输出:
true