Open In App

Scala Char max() method with example

Last Updated : 03 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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

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

Return Type: It returns the character 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 = ('F').max('A')
          
        // Displays output
        println(result)
      
    }


Output:

F

Example: 2#




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


Output:

a


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads