Learn Kotlin – Hello world and Basic Data Types

Since, Kotlin is already a official programming language for Android Apps development, I have been learning Kotlin lately. In this post, i will take you through basic hello world skeleton program to data types, variables in Kotlin.

Hello World Program for Kotlin

fun main(args: Array) {
    println("Hello World!")

main is the entry point in the kotlin program.

Variables/Values in Kotlin

We can define either value or varaible in kotlin. So, what is the difference between these two declarations?

var a : Int = 3 vs val a : Int = 3

When you declare var then you can change the value later whereas if you declare val then you cannot change the value later. val  makes the variable declaration immutable.

Data Types

kotlin provides data types like Java, but unlike the java data type starts with capital letter.


val a : Int = 3;
val b : Float = 3.0f;
val d : Double = 4.9;
val l : Long = 3494949494949

Let us see what size of data can each type store.


Character and String

var a : Char = 'd'
val b : Char = 'e'
val name : String = "Sudeep"

Char can store one character whereas a String can store group of character.


Like other programming languages, kotlin provides boolean data type which can store either true or false.

var isTrue : Boolean = false
var isFalse : Boolean = true

These are the basic data types in Kotlin, we have more complex data types such as Arrays, Collection and Ranges which we will discuss in future post.

One thought on “Learn Kotlin – Hello world and Basic Data Types”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.