Skip to content
Justice Tech School

Reading Input

readln() reads a line and readlnOrNull() returns null at the end of input.

Example
val line = readlnOrNull() ?: "guest"
println("Hello $line")
val n = (readlnOrNull() ?: "0").toInt()
println(n * 2)

Exercise

Read a line.

()

Quiz Test

What does readlnOrNull do at end of input?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.