midKotlin
What is the difference between val and const?
Updated May 16, 2026
Short answer
const is compile-time constant, val is runtime immutable.
Deep explanation
const is used for primitives and strings at top level or object declarations.
Real-world example
API keys stored as constants.
Common mistakes
- Trying to use const with runtime values.
Follow-up questions
- Where can const be used?
- Is val mutable internally?