Kotlin does not show primitive types like int or float directly in code to keep things simple and safe. It uses regular types everywhere, but the compiler handles them efficiently behind the scenes.
Why Kotlin has no primitive types at source level
val number: Int = 10 val text: String = "Hello"
Kotlin uses types like Int and Double, but these are not primitive types at the source level.
The Kotlin compiler converts these types to primitives like int or double when it compiles the code for better performance.
val age: Int = 25 val price: Double = 99.99
val name: String = "Alice" val isActive: Boolean = true
This program shows how Kotlin uses types like Int and Double without exposing primitive types directly.
fun main() { val number: Int = 42 val decimal: Double = 3.14 val message: String = "Kotlin hides primitives" println("Number: $number") println("Decimal: $decimal") println("Message: $message") }
Kotlin's approach improves code readability and safety by hiding primitive types.
The compiler automatically converts Kotlin types to JVM primitives for speed.
Common mistake: expecting Kotlin to have separate primitive and wrapper types like Java; Kotlin unifies them.
Use Kotlin's types for simplicity; the compiler handles performance optimizations.
Kotlin does not show primitive types in code to keep it simple and safe.
The compiler converts Kotlin types to primitives behind the scenes for better performance.
This design helps write clean, readable, and efficient code without extra effort.