Learn Kotlin - Introduction To Kotlin Cheatsheet - Codecademy
Learn Kotlin - Introduction To Kotlin Cheatsheet - Codecademy
Introduction to Kotlin
The main() Function
The main() function is the starting o point of
every Kotlin program and must be included in the code fun main() {
before execution. // Code goes here
}
Print Statements
A print statement outputs values to the output
terminal. println("Greetings, earthling!")
Using a println() statement will create a new print("Take me to ")
line in the output terminal after printing values, while a print("your leader.")
print() statement will not.
/*
Prints:
Greetings, earthling!
Take me to your leader.
*/
Comments
Comments are used to document what is happening
inside of a program and are ignored by the compiler. // This is a single-line comment
A single-line comment is used to write a comment on
one line, while a multiline comment is used to write /*
longer comments that span over multiple lines. This
comment
uses
multiple
lines
*/
Order of Execution
Code is read, compiled, and executed in top-down
order. fun main() {
println("I will be printed first.")
println("I will be printed
second.")
println("I will be printed third.")
}
/
/