It’s easy to get started with Kotlin using the Kotlin plugin integrated in IntelliJ IDEA. Benefit from code highlighting, code completion, refactoring, debugging, and other features available for Kotlin.
If you want to start from scratch, you can create a basic Kotlin application. Once you’ve created the application, you can dive deeper into Kotlin syntax.
Kotlin is an expressive and concise programming language that reduces common errors. Easily integrates into existing apps and is 100% interoperable with the Java language. Multiplatform. Code safely. Online courses. Easy to learn. Big community. Write less code.
IDEs?
IntelliJ IDEA IDE (Download, Install):
IntelliJ has a lot of versatility and stability. Kotlin was initially developed by the JetBrains team, which means there’s an extra level of compatibility between the two. Kotlin even has IntelliJ-specific tutorials and getting started guides.
Kotlin Playground (Online, Web Brower base):
You can try/ learn kotlin online without downloading or installing any ide on your computer.
Android Studio (Download, Install):
Android Studio provides the developers with fast tools for building apps on every type of Android device. Android Studio has had full support for Kotlin.
or
Text Editor (Download, Install)
Getting Started with IntelliJ IDEA
Create an application
Once you've installed IntelliJ IDEA, it's time to create your first Kotlin application.
- In IntelliJ IDEA, select File | New | Project.
- In the panel on the left, select Kotlin.
Enter a project name, select Console Application as the project template, and click Next.
By default, your project will use the Gradle build system with Kotlin DSL.
Go through and accept the default configuration, then click Finish.
Your project will open. By default, you see the file
build.gradle.kts
, which is the build script created by the Project Wizard based on your configuration. It includes thekotlin("jvm")
plugin and dependencies required for your console application.Open the
main.kt
file insrc/main/kotlin
.
Thesrc
directory contains Kotlin source files and resources. Themain.kt
file contains sample code that will printHello World!
.Modify the code so that it requests your name and says
Hello
to you specifically, and not to the whole world.- Introduce a local variable
name
with the keywordval
. It will get its value from an input where you will enter your name –readLine()
. - Use a string template by adding a dollar sign
$
before this variable name directly in the text output like this –$name
.
- Introduce a local variable
Run the application
Now the application is ready to run. The easiest way to do this is to click the green Run icon in the gutter and select Run 'MainKt'.
You can see the result in the Run tool window.
Enter your name and accept the greetings from your application!
Congratulations! You have just run your first Kotlin application.
Comments
Post a Comment