Menu
Kotlin Tutorial
Menu
Kotlin Classes
Menu
Kotlin Comments:
Comments are useful, when we want to explain a piece of code, and to make it more readable.
Types of Comments:
There are two types of comments.
- Single-line Comments
- Multi-line Comments
Single-line Comments:
Single-line comments starts with double forward slashes ( // )
The text after these two forward slashes is ignored by Kotlin compiler (this will not be executed)
The code example below explains the single-line comment.
// This is single-line comment
fun main(args: Array) {
println("Hello World!")
}
We can also add single line comment at the end of some code like the example below:
fun main(args: Array) {
println("Hello World!") // This is single-line comment
}
Multi-line Comments:
Multi-line comments starts with /* and ends with */.
Any documentation between /* */ this is ignored by Kotlin compiler (this will not be executed)
The code example below explains the multi-line comment.
/*This main functions prints
Hello World output It's accepting
some arguments also*/
fun main(args: Array) {
println("Hello World!")
}