In Java, data types specify the size and type of values stored in a variable. Since Java is statically typed, you must declare the type before use. Types are divided into Primitive and Non-Primitive. 8 Primitive Types byte (8-bit), short (16-bit), int (32-bit), long (64-bit), float (32-bit decimal), double (64-bit decimal), boolean, and char. Primitives are stored on the stack and are very fast. Non-Primitive (Reference) Types String (character sequences), Arrays (multiple values of same type), Classes & Interfaces (user-defined types). These refer to objects in heap memory. Wrapper Classes Wrapper classes wrap primitives into objects (int → Integer, double → Double, etc.). Why? Collections cannot store primitives — you need ArrayList<Integer>, not ArrayList<int>. Autoboxing…
Key Takeaways
8 primitive types; each has a corresponding wrapper class.
Collections require wrapper classes, not primitives.