Kotlin Syntax


Kotlin Syntax Basics

In the last step, we made a Kotlin file called Main.kt and wrote this simple program:

fun main() {   println("Hello World") }

Breaking It Down

fun — This keyword is used to define a function

main() — This is Kotlin's starting point. Whenever you run a Kotlin program, it always looks for this function first.

Curly braces {}— The code inside these brackets is what gets executed.

println() — This command is used to print a message to the screen. In our case, it prints `"Hello World"`.


No Semicolon Needed!

Unlike Java or C++, Kotlin doesn't require you to end each line with a `;`.

So your code looks cleaner and simpler.


What About `args: Array `?

Earlier versions of Kotlin (before 1.3) needed this version of the `main()` function:

fun main(args: Array<String>) {   
		println("Hello World") 
	}

This still works, but it’s not necessary anymore in newer versions.

You can use either — both are fine.


Prefer Learning by Watching?

Watch these YouTube tutorials to understand KOTLIN Tutorial visually:

What You'll Learn:
  • 📌 Kotlin Functions and Methods - Basics and Syntax || Kotlin || Android Tutorial
  • 📌 Kotlin Functions and Methods example. Basics and Syntax. Kotlin Android Tutorial. #7.1
Previous Next