Quick Revision GuideFast Concept Recall
Java Cheat Sheet & Quick Revision Notes
Rapid reference for Java primitives, StringBuilder, OOP, Collections, Stream API, ExecutorService, JDBC, and java.time.
1. Java Program Structure & Main Method
Essential entry point, compilation commands, and primitive data types.
| Type | Size | Default | Example |
|---|---|---|---|
| byte / short | 1 / 2 bytes | 0 | byte b = 127; |
| int / long | 4 / 8 bytes | 0 / 0L | long pop = 8_000_000_000L; |
| float / double | 4 / 8 bytes | 0.0f / 0.0d | double pi = 3.14159; |
| char | 2 bytes (UTF-16) | '\u0000' | char grade = 'A'; |
| boolean | 1 bit (JVM) | false | boolean ok = true; |
2. Strings, Arrays & Control Flow
String Pool vs StringBuilder, modern switch expressions, and array utilities.
- Always compare Strings with `.equals()`, never `==` (which compares object references).
- Use `StringBuilder` inside loops to avoid O(n^2) String allocations.
3. OOP, Interfaces, Records & Exceptions
Core OOP syntax, Java 16+ Records, and try-with-resources.
4. Collections, Generics & Java 8+ Streams
Everyday List, Set, Map, and Stream API operations.
| Collection | Ordering | Lookup | Nulls |
|---|---|---|---|
| ArrayList | Insertion order | O(1) by index | Allowed |
| LinkedList | Insertion order | O(n) by index | Allowed |
| HashSet | Unordered | O(1) avg | 1 null |
| TreeSet | Sorted (Red-Black) | O(log n) | No nulls |
| HashMap | Unordered | O(1) avg | 1 null key |
| TreeMap | Sorted keys | O(log n) | No null key |
5. Multithreading, JDBC & Date/Time
ExecutorService, PreparedStatement, and java.time essentials.