Scala List addString() method with example
The addString() method is utilized to append all the elements of the list to a string builder.
Method Definition: def addString(b: StringBuilder): StringBuilder
Return Type: It returns the elements of the list to a string builder.
Example #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) } } |
chevron_right
filter_none
Output:
1352
Example #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) } } |
chevron_right
filter_none
Output:
1152
Recommended Posts:
- Scala List addString() method with a separator with example
- Scala List addString() method with a start, a separator and an end with example
- Scala Map addString() method with example
- Scala Iterator addString() method with example
- Scala Map addString() method with a separator with example
- Scala SortedMap addString() method with example
- Scala Map addString() method with a start, a separator and an end with example
- Scala SortedMap addString() method with a separator with example
- Scala Iterator addString() method with a separator with example
- Scala SortedMap addString() method with a start, a separator and an end with example
- Scala Iterator addString() method with a start, a separator and an end with example
- Scala List take() method with example
- Scala List sum() method with example
- Scala List contains() method with example
- Scala List map() method with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

