← Kotlin Programming learning pathKotlin Programming · Module 2 of 10
Variables, types and strings
Use val, var, basic types and string templates.
📖 Key ideas
- val is read-only; var can change.
- Types: Int, Long, Double, Boolean, Char, String.
- Type inference: val x = 5 is Int.
- String templates: "Total: ${a + b}".
- Multi-line strings with triple quotes.
💡 Real-life example: val is writing in ink; var is writing in pencil.
valRead-only variable
varMutable variable
String template$name or ${expr} inside strings
Type inferenceCompiler deduces type