Factorial Program in Java: Loop, Recursion, Streams and BigInteger
Factorial in Java with a loop, recursion, streams and BigInteger, showing exactly where int (13!) and long (21!) overflow and computing 100! with BigInteger.
Factorial in Java with a loop, recursion, streams and BigInteger, showing exactly where int (13!) and long (21!) overflow and computing 100! with BigInteger.
Five Fibonacci implementations in Java with measured call counts, a recursion-tree diagram showing why naive recursion is exponential, memoization, the long overflow at fib(93) and BigInteger.
Reverse a number, palindrome, Armstrong, perfect and strong numbers in Java, each with a dry-run table, real output and the int-overflow trap in reversing.
Five ways to check a prime number in Java: naive, square root, 6k+-1, Sieve of Eratosthenes and BigInteger.isProbablePrime, with measured timings and a program to print primes in a range.
Wrapper classes in Java explained with real output: the eight wrappers, autoboxing and unboxing, the Integer cache (127 vs 128), NullPointerException on unboxing, equals traps, NaN and negative zero.
Enum in Java explained with a runnable program: generated methods, fields and constructors, constant-specific bodies, switch and pattern matching, EnumMap and EnumSet, and the enum singleton.
Lambda expressions in Java explained with a runnable program: syntax forms, target typing, the four method-reference kinds, variable capture, this, and what javac actually generates.
How java.util.HashMap works inside: hash spreading, bucket index, load factor and resize, collision handling and treeification, with a runnable program that peeks into the table and prints real output.
All 15 JEPs in JDK 21: which became final (virtual threads, record patterns, pattern matching for switch, sequenced collections, Generational ZGC, the KEM API) and which are still preview or incubator, each with a short example and real output from JDK 21, plus interview questions.
Everything that became final between Java 12 and Java 17, with examples and real output from JDK 17: records, sealed classes, text blocks, switch expressions, pattern matching for instanceof, helpful NullPointerException messages, the RandomGenerator API and strong encapsulation of JDK internals, plus interview questions.