Scala Iterator addString() method with example Last Updated : 30 Jun, 2019 Comments Improve Suggest changes Like Article Like Report The addString() method belongs to the concrete value members of the class AbstractIterator. It is defined in the class IterableOnceOps. It is utilized to append the elements of the Scala Iterator to a String Builder. Method Definition : def addString(b: StringBuilder): StringBuilder Return Type : It returns the String Builder to which the elements were appended. Example #1: Scala // Scala program of addString() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating an Iterator val iter = Iterator(7, 6, 8, 1) // Applying addString method val result = iter.addString(new StringBuilder()) // Displays output println(result) } } Output: 7681 Example #2: Scala // Scala program of addString() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating an Iterator val iter = Iterator(7.7, 6.1, 8.6, 1.1) // Applying addString method val result = iter.addString(new StringBuilder()) // Displays output println(result) } } Output: 7.76.18.61.1 Comment More infoAdvertise with us Next Article Scala Iterator addString() method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Similar Reads 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 // Scala program of addString() // method // Creati 1 min read Scala Map addString() method with example The addString() method is utilized to add the elements of the map to the String Builder. Method Definition: def addString(b: StringBuilder): StringBuilder Return Type: It returns the elements in the String Builder. Example #1: Scala // Scala program of addString() // method // Creating object object 1 min read Scala Iterator addString() method with a separator with example This method is same as addString() method but here we can even include a separator between all the elements of an Iterator. Method Definition : def addString(b: StringBuilder, sep: String): StringBuilder Where, sep is the separator. Return Type :It returns the elements of an iterator in the String B 1 min read Scala Map iterator method with example The iterator method is utilized to give an iterator. Method Definition: def iterator: Iterator[(A, B)] Return Type: It returns a non-empty iterator for non-empty map and returns an empty iterator for empty map. Example #1: Scala // Scala program of iterator // method // Creating object object GfG { 1 min read Scala Iterator sum() method with example The sum() method belongs to the concrete value members of the class AbstractIterator. It is defined in the classes TraversableOnce and GenTraversableOnce. It adds the elements of the stated collection. Method Definition: def sum: A Return Type: It returns the sum of all the elements in the stated it 1 min read Like