Skip to content
Related Articles

Related Articles

Scala Short max() method with example

View Discussion
Improve Article
Save Article
  • Last Updated : 11 Nov, 2019
View Discussion
Improve Article
Save Article

The max() method is utilized to find the maximum of the two specified Short types.

Method Definition: def max(that: Short): Short

Return Type: It returns the number of type Short with the maximum value.

Example: 1#




// Scala program of max()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying max() method 
        val result = (-1000).max(999)
          
        // Displays output
        println(result)
      
    }

Output:

999

Example: 2#




// Scala program of max()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying max() method
        val result = (990).max(1000)
          
        // Displays output
        println(result)
      
    }

Output:

1000

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!