📜  Scala Char abs() 方法与示例

📅  最后修改于: 2022-05-13 01:54:24.947000             🧑  作者: Mango

Scala Char abs() 方法与示例

abs()方法用于查找指定字符的绝对值。

示例: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)
      
    }
} 
输出:
a

示例: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)
      
    }
} 
输出:
B