Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Practice Problems
  • Python
  • C
  • C++
  • Java
  • Courses
  • Machine Learning
  • DevOps
  • Web Development
  • System Design
  • Aptitude
  • Projects
Open In App
Next Article:
Scala Iterator product() method with example
Next article icon

Scala Iterator mkString() method with example

Last Updated : 13 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

The mkString() method belongs to the concrete value member of the class Abstract Iterator. It is utilized to display all the elements of the collection in a string.
Method Definition:

  val result = iter.mkString  

Here, we are storing string in result variable.
Return Type:
It returns the string representation of the stated collection.
Example #1:




// Scala program of mkString()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Creating an Iterator 
        val iter = Iterator(3, 6, 15, 19, 21)
          
        // Applying mkString method
        val result = iter.mkString
          
        // Displays output
        println(result)
      
    }
}
 
 
Output:
  36151921  

Example #2:




// Scala program of mkString()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Creating an Iterator 
        val iter = Iterator(0, 0, 1)
          
        // Applying mkString method
        val result = iter.mkString
          
        // Displays output
        println(result)
      
    }
}
 
 
Output:
  001  


Next Article
Scala Iterator product() method with example
author
nidhi1352singh
Improve
Article Tags :
  • Scala
  • Scala
  • Scala-Method

Similar Reads

  • Scala Iterator min() method with example
    The min() method belongs to the concrete value members of the class AbstractIterator. It is defined in the classes IterableOnceOps. It is utilized to find the smallest element. Method Definition : def min[B >: A](implicit ord: math.Ordering[B]): A Where, B is the type over which the ordering is d
    1 min read
  • Scala List mkString() method with example
    The mkString() method is utilized to display all the elements of the list in a string. Method Definition: def mkString: String Return Type: It returns all the elements of the list in a string. Example #1: // Scala program of mkString() // method // Creating object object GfG { // Main method def mai
    1 min read
  • Scala Map mkString() method with example
    The mkString() method is utilized to represent the elements of the map as a string. Method Definition: def mkString: String Return Type: It returns the elements of the map as a string. Example #1: // Scala program of mkString() // method // Creating object object GfG { // Main method def main(args:A
    1 min read
  • Scala Iterator next() method with example
    The next() method belongs to the Abstract Value Members of the class AbstractIterator. It is defined in the class Iterator. It gives the next element of the stated iterator and advance the iterator. Method Definition : def next(): A Return Type :It returns the next element of the stated collection.
    1 min read
  • Scala Iterator product() method with example
    The product() method belongs to the concrete value member of the class Abstract Iterator. It is utilized to Multiply all the elements of the stated collection. Method Definition: val result = iter.product Return Type: It returns the result obtained by multiplying all the elements of the stated itera
    1 min read
  • Scala Set mkString() method with example
    The mkString() method is utilized to display all elements of the set in a string. Method Definition: def mkString: String Return Type: It returns a string containing all the element of the set. Example #1: // Scala program of mkString() // method // Creating object object GfG { // Main method def ma
    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 program of iterator // method // Creating object object GfG { // Mai
    1 min read
  • Scala Iterator map() method with example
    The map() method belongs to the concrete value member of the class Abstract Iterator. It is utilized to build a new iterator by applying a function to each of the elements of the stated iterator. Method Definition: def map[B](f: (A) => B): Iterator[B] where, B is the element type of the returned
    2 min read
  • Scala Iterator zip() method with example
    The zip() method belongs to the concrete value member of the class Abstract Iterator. It is defined in the class Iterator. Method Definition: val result = iter.zip(iter1) Return Type: It returns a new Scala iterator holding pairs of corresponding elements in the iterator and the size of the number o
    1 min read
  • Scala Iterator seq() method with example
    The seq() method belongs to the concrete value members of the class Iterable. It is helpful in visualizing the sequential view of the stated collection. It has a time complexity of O(1). Method Definition: def seq: Iterator[A] Return Type: It returns a sequential view of the iterator. Example : // S
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences