📌  相关文章
📜  Scala List addString() 方法与示例

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

Scala List addString() 方法与示例

addString()方法用于将列表的所有元素附加到字符串构建器。

示例 #1:

// Scala program of addString()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Creating a list
        val m1 = List(1, 3, 5, 2)
          
        // Applying addString method
        val res = m1.addString(new StringBuilder())
          
        // Displays output
        println(res)
      
    }
}
输出:
1352

示例 #2:

// Scala program of addString()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Creating a list
        val m1 = List(1, 1, 5, 2)
          
        // Applying addString method
        val res = m1.addString(new StringBuilder())
          
        // Displays output
        println(res)
      
    }
}
输出:
1152