Write your First Line of Code in Kotlin for Android!

Vish Katyan
2 min readJun 27, 2023

--

Kotlin is the easiest statically typed, general-purpose high-level programming language used in Android Development.

In 2017, Google announced Kotlin as an official programming language for Android development. At the Google I/O conference held in May 2017, Google declared Kotlin a first-class language for Android app development, alongside Java. This means developers can use Kotlin to build Android applications with full support and integration from the official Android development tools and libraries.

Write Your First Line of Code in Kotlin!

You only need an updated browser with an internet connection to compile and run your first LOC (Line of Code) in kotlin.

In your browser, open https://developer.android.com/training/kotlinplayground?authuser=1, this will open a browser-based programming tool.

You will see the interface similar to the screenshot attached.

Kotlin Playground

Run the First Program

To run, click on the green triangle button and see what happens.

Hello World!

The above is the output that will generate.

Now, let’s understand what it really means.

Understand the Program

fun

fun means the function in kotlin programming language. A function contains some line of code to perform some specific task.

fun main()
  1. main is the function name, it is like the entry point not for kotlin but for every programming language. It is the function that is called when you run the program.
  2. The Parenthesis () contains some argument i.e., input to the function.
fun main()
{
}

The curly braces {} contain a block of code to be executed.

fun main()
{
println("Hello World!")
}
  1. The println() tells the system to print some lines.
  2. As you can see inside the parenthesis (), there exists a quotation, which means you tell the system to print as exactly as given inside it.

So, there it is. The smallest Kotlin program. Hope you like it. You can also Buy Me A Coffee.

Thankyou :)

--

--

Vish Katyan

Hi I am Vishakha, a blogger, content creator and a developer.