Kotlin Programming Language

Kotlin — Complete Tutorial

Learn Kotlin from absolute zero. Every topic explained simply with real examples you can edit and understand quickly.

🟩 Beginner Friendly ▶ Live Code Editor 📚 26 Topics
Your Progress3% complete
Live Kotlin Lab

Edit the Kotlin example below and click Run to preview expected output notes.

kotlin-lab.kt
📝 Edit Code
👁 Live Preview
💡 Try this: modify values and method logic, then run again.
∙ Chapter 001

Kotlin Tutorial

Learn Kotlin Tutorial with a small example you can edit and run.

📝Syntax
fun main(){
  // ...
}
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

tutorial.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
println("Welcome to Kotlin")Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin Tutorial
∙ Chapter 002

Kotlin HOME

Learn Kotlin HOME with a small example you can edit and run.

📝Syntax
fun main(){
  // ...
}
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

home.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
println("Welcome to Kotlin")Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin HOME
∙ Chapter 003

Kotlin Intro

Learn Kotlin Intro with a small example you can edit and run.

📝Syntax
fun main(){
  // ...
}
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

intro.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
println("Welcome to Kotlin")Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin Intro
∙ Chapter 004

Kotlin Get Started

Learn Kotlin Get Started with a small example you can edit and run.

📝Syntax
fun main(){
  // ...
}
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

get-started.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
println("Welcome to Kotlin")Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin Get Started
Kotlin Basics
∙ Chapter 005

Kotlin Syntax

Learn Kotlin Syntax with a small example you can edit and run.

📝Syntax
fun main(){
  // ...
}
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

syntax.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
val score = 82Declares a variable (val = immutable, var = mutable).
val result = if (score >= 75) "Pass" else "Fail"Declares a variable (val = immutable, var = mutable).
println(result)Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin Syntax
∙ Chapter 006

Kotlin Output

Learn Kotlin Output with a small example you can edit and run.

📝Syntax
println("Hello")
print("No newline")
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

output.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
print("Hi")Prints output.
print(" ")Prints output.
println("Kotlin")Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin Output
∙ Chapter 007

Kotlin Comments

Learn Kotlin Comments with a small example you can edit and run.

📝Syntax
// single-line
/* multi-line */
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

comments.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
/* Multi-lineKotlin line.
comment */Kotlin line.
println("Comments don't change output")Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin Comments
∙ Chapter 008

Kotlin Variables

Learn Kotlin Variables with a small example you can edit and run.

📝Syntax
val name: String = "Mana"
var age = 21
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

variables.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
val name = "Mana"Declares a variable (val = immutable, var = mutable).
var level = 1Declares a variable (val = immutable, var = mutable).
level += 1Kotlin line.
println(" level ")Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin Variables
∙ Chapter 009

Kotlin Data Types

Learn Kotlin Data Types with a small example you can edit and run.

📝Syntax
val n: Int = 7
val pi: Double = 3.14
val ok: Boolean = true
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

data-types.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
val a: Int = 10Declares a variable (val = immutable, var = mutable).
val b: Double = 3.5Declares a variable (val = immutable, var = mutable).
val ok: Boolean = trueDeclares a variable (val = immutable, var = mutable).
val ch: Char = 'A'Declares a variable (val = immutable, var = mutable).
println(", , , ")Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin Data Types
∙ Chapter 010

Kotlin Operators

Learn Kotlin Operators with a small example you can edit and run.

📝Syntax
val sum = a + b
val gt = a > b
val mod = a % b
Example (Edit & Run)

Edit the Kotlin code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).

operators.kt
📝 Edit Code
👁 Output
💡 Tip: keep a // Expected Output: line so the output panel has something to show.
🔍Line-by-line
LineMeaning
fun main() {Program entry point.
val a = 7Declares a variable (val = immutable, var = mutable).
val b = 3Declares a variable (val = immutable, var = mutable).
println(a + b)Prints output.
}Kotlin line.
🏢Real-world
  • 1Kotlin is widely used for Android apps and JVM backends.
Common Mistakes
  • 1Mixing up val vs var and mutating unexpectedly.
Best Practices
  • 1Prefer val by default and keep functions small and clear.
📖Summary & Practice
  • 1Edit the example and rerun to learn faster.
  • 2Use readable Kotlin first; optimize later.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one value and predict the output.
  • 2Add one edge case and handle it.
  • 3Explain the rule in 1 sentence.
📈SEO

Keywords (topic intent):

Kotlin JVM Kotlin Operators