当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Scala Char toString()用法及代码示例


toString()方法用于将陈述的字符转换为String。

函数定义: def toString: String

返回类型: It returns the String representation of the stated character.



示例:1#

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

示例:2#

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


相关用法


注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Scala Char toString() method with example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。