Write a Scala program to check the largest number among three given integers.
object scala_basic { def test(x: Int, y: Int, z: Int): Int = { List(x, y, z).max } def main(args: Array[String]): Unit = { println("Result: " + test(1,2,3)); println("Result: " + test(1,3,2)); println("Result: " + test(1,1,1)); println("Result: " + test(1,2,2)); } }
Sample Output:
Result: 3 Result: 3 Result: 1 Result: 2
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer