Comments in Kotlin


Comments Definition and Overview

  • The text preceded by // is the single line comments in Kotlin.
  • The text line from /* to */ is the traditional comment or multi-line comments in Kotlin
  • Comments are neglected by Kotlin compiler.
  • Comments are designed for the better understanding of code and functionality and changes in the program. 

In Kotlin, there are two types of comments in Kotlin similar to C, C++, and Java.

Types

  • Single Line Comments
  • Multi Line Comments

Syntax

// Single Line Comment


/* 
Multi
Line
Comments 
*/

Example Program

/* Comments Example Program
   The program prints "Comments Example in kotlin" on the screen.
   Multi-line Comments
 */

fun main(args: Array<String>) {

   // prints Comments Example in kotlin - single line comments
   println("Comments Example in kotlin")

}

Sample Output

Comments Example in kotlin