0% found this document useful (0 votes)
57 views

Learn Kotlin - Introduction To Kotlin Cheatsheet - Codecademy

The document provides an introduction to basic Kotlin concepts including the main() function, print statements, comments, and order of execution. The main() function defines the starting point of a Kotlin program. Print statements output values to the terminal, with println() creating a new line and print() not. Comments are used to document code and are ignored by the compiler, with single-line and multiline comments available. Code is executed in the order it is written from top to bottom.

Uploaded by

Diprot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Learn Kotlin - Introduction To Kotlin Cheatsheet - Codecademy

The document provides an introduction to basic Kotlin concepts including the main() function, print statements, comments, and order of execution. The main() function defines the starting point of a Kotlin program. Print statements output values to the terminal, with println() creating a new line and print() not. Comments are used to document code and are ignored by the compiler, with single-line and multiline comments available. Code is executed in the order it is written from top to bottom.

Uploaded by

Diprot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Cheatsheets / Learn Kotlin

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.")
}

/
/

You might also like