Scala Console | println, printf and readLine Last Updated : 28 Nov, 2022 Comments Improve Suggest changes Like Article Like Report Console implements functions for displaying the stated values on the terminal i.e, with print, println, and printf we can post to the display. It is also utilized in reading values from the Console with the function from scala.io.StdIn. It is even helpful in constructing interactive programs. Let's discuss it in detail and also lets see some examples related to it. println: It is utilized in putting down values to the Console and moreover computes a trailing newline. we can pass any types as argument to it.Print: It is equivalent to println but it does not computes any trailing line. It puts down the data to the beginning of the line.printf: This is helpful in writing format strings and also places extra arguments. Example: Scala // Scala program of print // functions // Creating an object object GfG { // Main method def main(args: Array[String]) { // Applying console with println Console.println("GeeksforGeeks") // Displays output with no // trailing lines print("CS") print("_portal") // Used for a newline println() // Displays format string printf("Age = %d", 24) } } Output:GeeksfoGeeks CS_portal Age = 24The println and Console.println both are equivalent.readLine(): It is a method in which user gives inputs in the pattern of String from the keyboard. Example: Scala // Scala program of readLine() // method // Creating an object object GfG { // Main method def main(args: Array[String]) { // Applying a loop while (true) { // Reads the line from the Console val result = scala.io.StdIn.readLine() // Displays the string that is // given by the user printf("Enter the String: %s", result) //prints newline println() } } } Output://giving user defined inputs GfG //output by readline Enter the String: Gfg //again giving inputs Nidhi //output Enter the String: Nidhi Here, the while loop is infinite in nature and after giving user inputs the variable will contains that (GfG) string and if again we given any input then the variable will contain that (Nidhi) input. Comment More infoAdvertise with us Next Article Scala Console | println, printf and readLine nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Basics Similar Reads How to Print RDD in scala? Scala stands for scalable language. It was developed in 2003 by Martin Odersky. It is an object-oriented language that provides support for functional programming approach as well. Everything in scala is an object e.g. - values like 1,2 can invoke functions like toString(). Scala is a statically typ 4 min read How to Read and Write CSV File in Scala? Data processing and analysis in Scala mostly require dealing with CSV (Comma Separated Values) files. CSV is a simple file format used to store tabular data, such as a spreadsheet or database. Each line of a CSV file is plain text, representing a data row, with values separated by commas (,). Readin 5 min read Command Line Argument in Scala The arguments which are passed by the user or programmer to the main() method are termed as Command-Line Arguments. main() method is the entry point of execution of a program. main() method accepts an array of strings. runtime. But it never accepts parameters from any other method in the program. Sy 2 min read How to read and write JSON files in Scala? Scala is frequently used for reading and writing JSON files in a variety of applications, particularly it includes data transmission.Table of ContentSteps for reading JSON files in Scala:Steps for writing JSON files in Scala:Steps for reading JSON files in Scala:When reading JSON files in Scala we f 3 min read How to Install Scala in Linux? Prerequisite: Introduction to Scala Before, we start with the process of Installing Scala on our System. We must have first-hand knowledge of What the Scala Language is and what it actually does? Scala is a general-purpose, high-level, multi-paradigm programming language. It is a pure object-oriente 3 min read Like