Scala immutable TreeSet isEmpty() method
In Scala immutable TreeSet class isEmpty() is utilized to check if the TreeSet is empty or not.
Method Definition: def isEmpty: Boolean
Return Type: It returns true if the TreeSet is empty or else it returns false.
Example #1:
import scala.collection.immutable. _
object GfG
{
def main(args : Array[String])
{
val q 1 = TreeSet( 1 , 2 , 3 , 4 , 5 )
println(q 1 )
val result = q 1 .isEmpty
print( "TreeSet is empty: " + result)
}
}
|
Output:
TreeSet(1, 2, 3, 4, 5)
TreeSet is empty: false
Example #2:
import scala.collection.immutable. _
object GfG
{
def main(args : Array[String])
{
val q 1 = TreeSet[Int]()
println(q 1 )
val result = q 1 .isEmpty
print( "TreeSet is empty: " + result)
}
}
|
Output:
TreeSet()
TreeSet is empty: true
Last Updated :
19 Apr, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...