Ad space (banner)
๐ŸŽฏKotlin Lessons
Lesson 2 / 68

Your First Output (println)

In this lesson you will learn the basic way to print output in Kotlin with println, and get a feel for what kind of language Kotlin is. This is for anyone searching for "Kotlin println how to use".

println() displays text on the screen. Kotlin is the modern language Google officially recommends for Android app development. It interoperates closely with Java while offering a more concise and safer syntax.

The sample code writes the single line println("Hello, Kotlin!") inside a fun main() function. Not needing the fixed scaffolding of a class declaration as Java does - you can simply run it - is part of Kotlin's appeal.

A common stumbling block for beginners is forgetting fun main(). Unlike some languages you cannot simply start writing statements; in Kotlin the work has to go inside a function.

In real-world development, printing to the screen is the first step in checking behaviour and debugging. A design that takes null safety seriously, cutting down runtime errors, is another reason Kotlin is so well regarded.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Kotlin directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)