Skip to content
Related Articles

Related Articles

Scala Char max() method with example

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

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!