Kotlin Basic Types: Int, Double, Boolean, Char
Learn the primitive-equivalent types in Kotlin and how type inference works.
Kotlin Basic Types: Int, Double, Boolean, Char is a free Kotlin Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Kotlin's Type System
Integer Types
val age: Int = 25
val population: Long = 8_000_000_000L
val score: Short = 100
val flags: Byte = 0b00001111Floating-Point Types
val pi: Double = 3.14159
val gravity: Float = 9.81f
val result = pi * 2 // Double arithmeticBoolean Type
val isOnline: Boolean = true
val isEmpty = false
println(!isOnline) // false
println(isOnline && !isEmpty) // trueChar Type
val letter: Char = 'A'
val digit: Char = '7'
val emoji: Char = '\u2764' // heart
println(letter.code) // 65 (ASCII)Type Inference in Action
val count = 10 // Int
val ratio = 0.75 // Double
val active = true // Boolean
val initial = 'K' // CharNumeric Underscores for Readability
val million = 1_000_000
val hex = 0xFF_AA_BB
val binary = 0b1010_1010
println(million) // 1000000Number Conversion
val x: Int = 42
val y: Long = x.toLong() // explicit
val z: Double = x.toDouble()
println("$y $z")String Is Not a Primitive
val name: String = "Kotlin"
println(name.length) // 6
println(name.uppercase()) // KOTLIN
println(name[0]) // K (Char)Any, Nothing, Unit
fun greet(): Unit { println("Hi") }
fun fail(): Nothing { throw Exception("!!") }
val x: Any = 42 // Any accepts anythingChecking Types with is
val obj: Any = "Hello"
if (obj is String) {
println(obj.length) // smart cast: no cast needed!
}Quick Check
Recap
Frequently asked questions
Is the “Kotlin Basic Types: Int, Double, Boolean, Char” lesson free?
Yes — the full text of “Kotlin Basic Types: Int, Double, Boolean, Char” is free to read here on the web, and the Kotlin Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Academy course, upgrade to CoddyKit PRO.
What will I learn in “Kotlin Basic Types: Int, Double, Boolean, Char”?
Learn the primitive-equivalent types in Kotlin and how type inference works. You practise Kotlin Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Kotlin Academy?
No prior experience is required. Kotlin Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Kotlin Basic Types: Int, Double, Boolean, Char” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Kotlin Academy lesson?
Yes. Every Kotlin Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Setting Up Kotlin: REPL, IntelliJ & Online Playground
- val vs var: Immutability From Day One
- Kotlin Basic Types: Int, Double, Boolean, Char
- Your First Kotlin Program: main, println & Input