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