Getting Started with Kotlin

What is Kotlin?

  • Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference.
  • Kotlin is designed to interoperate fully with Java, and the Java virtual machine (JVM) version of its standard library depends on the Java Class Library, but type inference allows its syntax to be more concise (drastically reduced the amount of boilerplate code). Existing Java code can be called from Kotlin, and Kotlin code can be used from Java.
  • Kotlin is a free and open source project under the Apache 2.0 license.
  • Kotlin is sponsored by JetBrains and Google through the Kotlin Foundation.
  • Kotlin has been Google’s preferred language for Android app development since 7 May 2019
  • Cross-platform is the capability of software or hardware to run identically on different platforms
  • Statically typed is a programming language characteristic in which variable types are explicitly declared and thus are determined at compile time.
  • General Purpose Programming is a language that is capable of creating all types of programs that is broadly applicable across application domains.
  • Type inference refers to the automatic detection of the data type of an expression in a programming language.
  • Boilerplate code or just boilerplate are sections of code that have to be included in many places with little or no alteration.

To get started, install a recent version of IntelliJ IDEA. Kotlin is bundled with IntelliJ IDEA starting from version 15. You can download the free Community Edition from JetBrains.

Creating a new project

Step 1: Once the IntelliJ IDEA Community Edition is installed. Open the IDE and go to Create a new Project from File | New. Select the Kotlin | JVM | IDEA project type.

Step 2: Give your project a name and select an SDK version.

Now new project is created as seen in the below screenshot.

Step 3: Create a new Kotlin file under the source folder.

Name the file as below

Step 4: Once the file is created, add the main function which is the entry point to a Kotlin application. Add the below source code.

fun main() {
    println("Welcome to my First Kotlin Program")

Step 5: Run the application. Click the green Run icon in the gutter and select Run ‘MyappKt’.

Now you will see the result in Run tool window.



Learn more about  Kotlin Language Programming in the next upcoming Blog Articles.

Happy Learning!