Java Primitive Data Types
Java data types are divided into two categories: Primitive Types (which store raw values directly in memory) and Reference Types (like String, Arrays, and Objects). Java has 8 built-in primitive types optimized for speed and memory efficiency.
"Primitive types are like physical coins in your pocket: you hold the exact value. Reference types are like a bank account slip: they point to where the money is stored."
Deep Dive: How It Works
Whole numbers: `byte` (8-bit), `short` (16-bit), `int` (32-bit, default), `long` (64-bit, suffix L).
Floating points: `float` (32-bit, suffix f), `double` (64-bit, default decimal type).
Boolean: `boolean` (true or false).
Character: `char` (16-bit Unicode character, enclosed in single quotes 'A').
Syntax Blueprint
int count = 42; double price = 19.99; char grade = 'A'; boolean active = true;
Use single quotes for char ('Z') and double quotes for String ("Hello").
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Using double quotes for char: char c = "A";Why it happens: "A" is a String object, not a primitive char.
How to fix: Use single quotes: char c = 'A';
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Store product details
Declare an int variable "items" with value 5.
Declare a double variable "totalCost" with value 49.95.
Print "Items: " + items and "Total: $" + totalCost on separate lines.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.