Open In App

Scala Char abs() method with example

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

The abs() method is utilized to find the absolute value of the stated character.

Method Definition: def abs: Char

Return Type: It returns Char.

Example: 1#




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


Output:

a

Example: 2#




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


Output:

B


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

Similar Reads