max()方法用於返回兩個指定的int數的最小值。
函數定義: (First_Number).min(Second_Number)
返回類型: It returns true the minimum value of the two specified int numbers.
範例1:
// Scala program of Int min()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying min method
val result = (5).min(9)
// Displays output
println(result)
}
}
輸出:
5
範例2:
// Scala program of Int min()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying max method
val result = (5).min(5)
// Displays output
println(result)
}
}
輸出:
5
相關用法
- Scala Set ++()用法及代碼示例
- Scala Set &~()用法及代碼示例
- Scala Map last()用法及代碼示例
- Scala Int abs()用法及代碼示例
- Scala Set contains()用法及代碼示例
- Scala Set take()用法及代碼示例
- Scala Set map()用法及代碼示例
- Scala Set sum()用法及代碼示例
- Scala Set min()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Scala Int min() method with example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。