HashMap — not thread-safe, allows null. HashTable — thread-safe, no null. Legacy class.Simple analogy: HashMap is like a personal notebook — fast to write in, but if two people write simultaneously, pages might tear. HashTable is like a bank ledger with a lock — safe but slower.Why it matters: Understanding HashMap internals (hashing, collisions, load factor) is essential. Nearly every Java application uses HashMap extensively.HashMap:- Not thread-safe. Allows one null key, multiple null values.- Default capacity 16, load factor 0.75.- Uses array + linked list + red-black tree (Java 8+ at 8+ entries).javaHashMap<String, Integer> map = new HashMap<>();map.put(null, 1); // OKmap.put("key", null); // OKmap.put("name", 42);map.getOrDefault("age", 0); // 0map.computeIfAbsent("score", k -> 100);HashTable:- Thread-safe (all methods synchronized). No null keys or values.- Slower. Legacy class from Dictionary.javaHashtable<String, Integer> table = new Hashtable<>();table.put("name", 42);// table.put(null, 1); // NullPointerException!// table.put("k", null); // NullPointerException!Modern alternative — ConcurrentHashMap:javaConcurrentHashMap<String, Integer> cm = new ConcurrentHashMap<>();cm.put("name", 42);cm.compute("name", (k, v) -> v + 1); // atomic update- HashMap — single-threaded (default).- ConcurrentHashMap — multi-threaded (modern).- HashTable — legacy, never use in new code.