Java is a class-based, object-oriented programming language designed for write once, run anywhere (WORA) portability through the Java Virtual Machine (JVM). Originally released in 1995, Java combines strong static typing with automatic memory management, making it a foundation for enterprise applications, Android development, and distributed systems. The language prioritizes readability, stability, and backward compatibility, allowing decades-old code to run on modern JVMs. As of Java 25 (LTS, September 2025) and Java 26 (March 2026), the language continues to evolve rapidly with virtual threads, records, pattern matching, sealed classes, stream gatherers, scoped values, and HTTP/3 support, making it one of the most actively developed platforms in the industry.
What This Cheat Sheet Covers
This topic spans 28 focused tables and 285 indexed concepts, 202 flashcards, 9 practice tests with 357 questions. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Primitive Data Types
Java's eight primitives are the only values that aren't objects. They hold raw numbers, characters, and booleans directly rather than as references, which is also why none of them can be null. The practical advice is short: reach for int and double by default, and drop to long, byte, or float only when range, binary handling, or memory genuinely calls for it.
| Type | Example | Description | |
|---|---|---|---|
int count = 100; | β’ 32-bit signed integer β’ default choice for whole numbers β’ range approximately Β±2.1 billion β’ overflow wraps silently, it never throws. | ||
long big = 9876543210L; | β’ 64-bit signed integer β’ a literal past the int range needs the L suffixβ’ used for timestamps, large counts, or IDs. | ||
double price = 99.99; | β’ 64-bit floating-point (IEEE 754 binary64) β’ default for decimal numbers β’ never for money, use BigDecimal. | ||
boolean active = true; | β’ Logical type holding true or false β’ no conversion to or from integers, so if (count) will not compile. | ||
char letter = 'A'; | β’ 16-bit UTF-16 code unit β’ single quotes only β’ range U+0000 to U+FFFF, so an emoji needs two chars. | ||
byte b = 127; | β’ 8-bit signed integer β’ range -128 to 127 β’ a literal outside that range is a compile error, not a warning. | ||
short s = 32000; | β’ 16-bit signed integer β’ range -32,768 to 32,767 β’ mainly for large arrays where the memory saving actually matters. | ||
float pi = 3.14f; | β’ 32-bit floating-point β’ requires f suffix β’ only ~7 significant digits against double's ~15. |