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.

TypeSizeDefaultExample
byte / short1 / 2 bytes0byte b = 127;
int / long4 / 8 bytes0 / 0Llong pop = 8_000_000_000L;
float / double4 / 8 bytes0.0f / 0.0ddouble pi = 3.14159;
char2 bytes (UTF-16)'\u0000'char grade = 'A';
boolean1 bit (JVM)falseboolean 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.

CollectionOrderingLookupNulls
ArrayListInsertion orderO(1) by indexAllowed
LinkedListInsertion orderO(n) by indexAllowed
HashSetUnorderedO(1) avg1 null
TreeSetSorted (Red-Black)O(log n)No nulls
HashMapUnorderedO(1) avg1 null key
TreeMapSorted keysO(log n)No null key

5. Multithreading, JDBC & Date/Time

ExecutorService, PreparedStatement, and java.time essentials.