main()
FunctionThe main()
function is the starting off point of every Kotlin program and must be included in the code before execution.
fun main() {// Code goes here}
A print statement outputs values to the output terminal.
Using a println()
statement will create a new line in the output terminal after printing values, while a print()
statement will not.
println("Greetings, earthling!")print("Take me to ")print("your leader.")/*Prints:Greetings, earthling!Take me to your leader.*/
Comments are used to document what is happening inside of a program and are ignored by the compiler.
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 is a single-line comment/*Thiscommentusesmultiplelines*/
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.")}