Hello World

Let’s start with a fun and popular introductory programming example: printing Hello world! to the console. To do so in Kotlin, we use the println() function. It takes any text in quotes and prints it to the console.

println("Hello world!")

We need to write this programming statement inside of a main function:

fun main() {
	println("Hello world!")

The main function is an entry point for every application; it takes any code that you’ve written as a set of instructions and executes in the appropriate manner. In this case, we told the main function to print out “Hello world!” and it did exactly that.

Add that bit of code in an empty .kt file, then compile and run! You should see ‘Hello world!’ displayed on the console.