Booleans
Create a true/false variable and print it.
1fun main() {
2 val isFalse = false
3 println(isFalse)
4}
$ kotlinc Main.kt -include-runtime -d Main.jar
$ java -jar Main.jar
false
Every line, explained
fun main() {- Every Kotlin program starts at the main function. When you run the program, Kotlin looks for fun main() and runs everything between its { and } from top to bottom.
val isFalse = false- A Boolean can store only one of two values: true or false, both lowercase.
println(isFalse)- println(...) prints whatever is inside the round brackets to the terminal, then moves to a new line. All lowercase, and no semicolon at the end; Kotlin does not need them. Printing a Boolean shows the word true or false.
}- This closing curly brace } ends the main function. In Kotlin every opening brace { must have a matching closing brace }.