Scala Char abs() 方法与示例
abs()方法用于查找指定字符的绝对值。
Method Definition: def abs: Char
Return Type: It returns Char.
示例: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