Comment

Reading Time: < 1 minuteCommenting code is a good practice, helping you and your fellow programmers understand and maintain the code.

Whatever you write in the comment is ignored by Kotlin compiler.

There are 2 types of comment in Kotlin

  • Single-line Comments
  • Mulit-line Comments

Single-Line Comments

To write single line Kotlin comment, you need to user //.

… and a complete example.

What will happen when // is removed from the program?

The second println will be pritned out as well.

Multi-Line Comments

There are 2 ways to do it.

Using //
In this case, you will have to write // in each line before writing the comment.

What if you have to write 20 lines of comment?
It is not a good idea of writing multiple lines of comment in Kotlin using //.
The good way in this case is /*..*/

Questions

I hope the description was understandable and clear. But if you have still questions, then leave me comments below! 😉

Have a nice a day! 🙂

 


 

Follow and like us:

Click to rate this post!
[Total: 0 Average: 0]

Leave a comment

stay informed!

Subscribe to receive exclusive content and notifications