Lecture 3 — Part 2: The Big 4 Functional Toolbelt
Today you unlock the compiler’s secret vision (it only counts missing-body methods), then you wield the Big 4 built-in interfaces: Predicate, Function, Consumer, Supplier.
“Missing Body” methods = counteddefault/static = ignored (they already have bodies)Big 4 = your cyber tools
The Compiler Scanner
Watch it ignore default/static and count only the missing-body method.
Abstract Count: 1
interface Processor { int process(int x); // Abstract => COUNTED default int doubleIt(int x) { return x * 2; } // Default => IGNORED static Processor identity() { return x -> x; } // Static => IGNORED } Valid Functional Interface (1 Abstract Method)
The compiler’s rule is simple: it counts only methods with no body. Default/static methods have bodies, so they’re ignored.
The Functional Toolbelt
Pick a tool. Type. Click. Feel powerful.
Predicate<T> — The Gatekeeper
A True/False machine: boolean test(T t)
Lambda: n -> n % 2 == 0
Verdict: waiting...
Predicate = returns True/FalseFunction = converts input -> outputConsumer = does something (returns nothing)Supplier = creates something (no input)
Power-up unlocked
You now know: the compiler counts only missing-body methods (abstract), and you can use the Big 4 interfaces to filter, transform, consume (side-effect), and supply values.
Sign In to Keep Going
You've reached the end of the free preview. Sign in — and upgrade to Plus or Pro — to keep going with DataStructure.
Full Access
Unlock all 13 lessons