📜  Scala SortedMap isEmpty() 方法与示例

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

Scala SortedMap isEmpty() 方法与示例

isEmpty()方法用于检查给定的 SortedMap 是否为空。

示例 #1:

// Scala program of isEmpty()
// method
import scala.collection.immutable.SortedMap
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Creating SortedMap
        val m1 = SortedMap(3 -> "geeks", 1 -> "for", 2 -> "cs", 3 -> "geeks")
          
        // Applying isEmpty method 
        val result = m1.isEmpty
          
        // Displays output
        println(result)
    }
}
输出:
false

示例 #2:

// Scala program of isEmpty()
// method
import scala.collection.immutable.SortedMap
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Creating SortedMap
        val m1 = SortedMap(2 -> 4)
          
        // Applying isEmpty method 
        val result = m1.isEmpty
          
        // Displays output
        println(result)
    }
}
输出:
false