Step 1 of 13
Install IntelliJ IDEA, create your first Kotlin project, understand the project structure
เริ่มต้นกับ Kotlin — ติดตั้ง IntelliJ IDEA, ทำความรู้จักโครงสร้างโปรเจกต์ และเขียนโปรแกรมแรก
Kotlin is a modern programming language that runs on the JVM. It is concise, type-safe, and works smoothly with Java. You can use Kotlin for backend services, Android apps, cross-platform projects, and more.
The current stable version is Kotlin 2.4.x with the K2 compiler. The K2 compiler is faster and gives better error messages than the old compiler.
You need two things:
Download IntelliJ IDEA from jetbrains.com/idea. It comes with Kotlin built in. No separate Kotlin installation needed.
To verify your setup, open IntelliJ IDEA and create a new Kotlin project:
Open the generated Main.kt file and replace the content:
fun main() {
val name = "Kotlin"
println("Hello, $name!")
}
Click the green play button next to main() to run it.
Diagram: A typical Kotlin/JVM project layout with source, test, and build files.
Loading diagram...
.kt — Kotlin source file extensionfun — keyword to declare a functionval — read-only variable (preferred)var — mutable variable (use only when needed)$variable — string template, inserts a variable value into a string| Feature | Java | Kotlin |
|---|---|---|
| Variable declaration | String name = "Kotlin"; | val name = "Kotlin" |
| Function | void greet() { ... } | fun greet() { ... } |
| Null | allowed by default | banned by default |
| Semicolons | required | optional |
| Getters/Setters | manual or Lombok | val/var properties |
You have Kotlin running. The next step is learning variables, data types, and null safety — the feature that makes Kotlin different from Java.