Kotlin – Comments

Comments are the statements that are used for documentation purpose. Comments are ignored by compiler so that don’t execute. We can also used it for providing information about the line of code. There are two types of comments in Kotlin.

  1. Single line comment.  
  2. Multi line comment.

1. Single line comment    // ….

Single line comment is used for commenting single line of statement. It is done by using ‘//’ (double slash). For example:

fun main(args: Array<String>) {
// this statement used for print
    println("Hello World!")
}

Output :

Hello World!

Multi line comment    /* … */

This is a multiline comment that can span over multiple lines. The Kotlin compiler ignores everything from /* to */. For example,

fun main(args: Array<String>) {
/* this statement
   is used
   for print */
    println("Hello World!")
}

Output :

Hello World!

I hope you found what you were looking for from this tutorial. If you want more Kotlin tutorials like this, then do join our Telegram channel for future updates.

Thanks for reading, have a nice day 🙂

Leave a Comment

Your email address will not be published.