Published Dec 15, 2022
Contribute to Docs

Comments are pieces of text within a Kotlin program that are ignored by the compiler. They can be text, symbols, or valid code meant to provide additional information to aid in understanding the program. Comments are good for a variety of reasons like explaining a code block or indicating some hints.

Single-line Comments

In Kotlin, single-line comments are created with two consecutive forward slashes //:

// Prints text in ("...")
println("The line above is a single line comment");

A single-line comment can also be used inline to comment after a line of code:

println("This is a single line comment") // Prints text in ("...")

Multi-line Comments

Multi-line comments are created by surrounding the lines with /* at the beginning and */ at the end:

The text in ("...")
would be only code to be executed
println("The line above is a multi-line comment");


The code in the following that is commented out will not execute when the program is run:

// Calculate sum of values
var operation = 100 + 50
// Output: 150

All contributors

Looking to contribute?

Learn Kotlin on Codecademy