带有示例的 Scala Float max() 方法
max()方法用于返回两个指定浮点数的最大值。
Method Definition: (First_Number).max(Second_Number)
Return Type: It returns the maximum value of the two specified float numbers.
示例 #1:
// Scala program of Float max()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying max method
val result = (5.9).max(9.0)
// Displays output
println(result)
}
}
输出:
9.0
示例 #2:
// Scala program of Float max()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying max method
val result = (5.0).max(5.0)
// Displays output
println(result)
}
}
输出:
5.0