The function readLine() in Kotlin is a function included in the standard library that allows reading a line of text from the console. It returns the read line as a string.

With the help of other special functions such as toInt(), toDouble() or toFloat(), the inputs that are read in as a string can be converted into other data types in order to be processed accordingly later in the program. Below are three examples just to make the principle of operation understandable. Later these functions will be explained in detail and sufficiently practiced.

Entering a number from the console:

Entering a float value from the console:

Entering a Double value from the console:


In Kotlin there are two functions to output data to the console: print() and println() (This function has already been used several times in the previous chapters 🙂 ). These two functions take an object to print to the console, usually a string.

The difference between print() and println() is that the print() function prints the passed text to the console, without Add a line break at the end. However, if you println() If you use this function, it will automatically add a line break to the end of the output. Below are some examples:

Leave a Comment

Your e-mail address will not be published. Required fields are marked with * marked