Scala immutable TreeSet min() method
Last Updated :
19 Apr, 2020
In Scala immutable TreeSet class the min() method is utilized to return the smallest element of the TreeSet.
Method Definition: def min: A
Return Type: It returns the smallest element of the TreeSet.
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 .min
print( "Smallest element in the TreeSet: " + result)
}
}
|
Output:
TreeSet(1, 2, 3, 4, 5)
Smallest element in the TreeSet: 1
Example #2:
import scala.collection.immutable. _
object GfG
{
def main(args : Array[String])
{
val q 1 = TreeSet( "u" , "a" , "i" , "o" , "e" )
println(q 1 )
val result = q 1 .min
print( "Smallest element in the TreeSet: " + result)
}
}
|
Output:
TreeSet(a, e, i, o, u)
Smallest element in the TreeSet: a
Share your thoughts in the comments
Please Login to comment...