Posts

Showing posts with the label Unboxing

Wrapper Classes & Boxing in Java & Kotlin

Primitive data types are fast and memory-efficient, but modern JVM programming often requires objects. Wrapper classes, boxing, and unboxing bridge this gap. This topic is extremely important for interviews, JVM internals, and performance discussions . Table of Contents Wrapper Classes Boxing & Unboxing Kotlin Internal Handling Java & Kotlin Interview Questions Conclusion 1. Wrapper Classes Wrapper classes are object representations of primitive data types . They allow primitives to work with collections, generics, and frameworks. Primitive Wrapper (Java) Kotlin Type Description int Integer Int Whole numbers, most commonly boxed type double Double Double Decimal values with double precision boolean Boolean Boolean True/false values for conditions char Character Char Single Unicode character 📌 In Java, primitives and wrappers are separate types. 📌 In Kotlin, this distinction is hidden but still exists in...