Primitive Types in Java

From the Java cheat sheet · Variables & Data Types · verified Jul 2026

Primitive Types

Java's eight built-in value types.

java
// Quick Reference
int i = 42;
long l = 42L;
double d = 3.14;
float f = 3.14f;
boolean b = true;
char c = 'A';
💡 int and double are the defaults; long needs L and float needs f suffixes.
⚡ char uses single quotes; double quotes always make a String, never a char.
📌 Primitives hold values directly and cannot be null (unlike wrapper objects).
🟢 Underscores in literals (1_000_000) are ignored by the compiler, purely visual.
typesprimitives

Continue with Java

Save the full cheat sheet or work through every related task.

More Java tasks

Back to the full Java cheat sheet