Scala 字符串toString()方法及示例

Scala 字符串toString()方法及示例

toString()方法是用来返回一个字符串对象本身的。

方法定义。String toString()

返回类型。它返回字符串对象。

例子: 1#

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

输出。

GEEKS

例如:2#

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

输出。

10

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程